I'm having trouble matching a wilcarded string in the sh
shell. The code is part of a configure.ac
so it usually gets the lamest shell available. I can't count on the Bash shell.
The code first executes:
LDNAME=`basename "$LD"`
And I sometimes get a string like ld -m x86_64
or ld -m elf64lppc
, but I want just ld
as a friendly display name.
I then perform a small fixup according to How to check substring in shell script bash?, Substring check in IF condition in shell script and if/else comparison with wildcard using a case
statement:
case "$LDNAME" in
"ld -m*") LDNAME=ld
;;
esac
The string fails to match and I get the original string back. I've also tried ld -m *
(without quotes) and a few other variations with the same result.
How do I match a wilcarded string in case statement using sh
shell?
This works but it is not very extensible:
if test "$LDNAME" = "ld -m elf_x86_64"; then
LDNAME=ld
fi
if test "$LDNAME" = "ld -m elf64lppc"; then
LDNAME=ld
fi