How to keep the single quotation mark after using $* in bin/sh or bin/bash

Viewed 50

I'm using a shell script wrapper to execute clang while I met the problem when I get $* and use $CLANG to exec $CLANG $*, the problem is that the option '-DPACKAGE_VERSION="2.2.0-pre"' become -DPACKAGE_VERSION="2.2.0-pre" after the wrapper.

It shows the error: clang-10: error: no such file or directory: '2.2.0-pre"'

My wrapper looks like:

#!/bin/sh

CLANG=${CLANG:-clang}

if [ `echo $* | grep -c "keyword"` -eq 1 ]; then
  exec $CLANG $*
else
  exec $CLANG $* -fsanitize=hextype
fi

Anyone has any idea to keep the single quotation mark after the bash?

1 Answers

Thanks to @Charles Duffy, "$@" (including the double quotes) works in my case.

Related