From: Johannes Sixt Date: Mon, 05 Sep 2011 07:03:30 GMT Subject: Re: [PATCH] shell portability: Use sed instead of non-portable variable expansion Message-ID: <4E647442.9000005@viscovery.net> In-Reply-To: <8762l73758.fsf@elisp.net> Am 9/5/2011 7:11, schrieb Naohiro Aota: > Variable expansions like "${foo#bar}" or "${foo%bar}" doesn't work on > shells like FreeBSD sh and they made the test to fail. This patch > replace such variable expansions with sed. > > Signed-off-by: Naohiro Aota > --- > > Testing on FreeBSD failed because of this "bash-ism". These are not bashism, but features require by POSIX. I'd rather suspect that the failures are not because FreeBSD sh does not have ${%} or ${#}, but rather that it interprets the meaning of the backslash in this case in a way different from other shells. > run_backend() { > echo "$2" | > - QUERY_STRING="${1#*\?}" \ > - PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%\?*}" \ What happens if you write these as QUERY_STRING=${1#*\?} \ PATH_TRANSLATED=$HTTPD_DOCUMENT_ROOT_PATH/${1%%\?*} \ i.e., drop the double-quotes? -- Hannes