Dale Visser
2014-02-21 22:08:02 UTC
I have a macro argument that I would like to place in a shell variable, but with a catch. I want to truncate it at the first space or comma. I have code that works for me (in Ubuntu), like this:
my_var="$1"
my_var=${my_var%%\ *}
my_var=${my_var%%,*}
However, I read at https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Shell-Substitutions.html#Shell-Substitutions that this construct "[does] not work with many traditional shells, e.g., Solaris 10 /bin/sh."
I am at a loss to figure out an acceptable "autoconf portable way" to accomplish this. I suspect some usage of m4_split (https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Text-processing-Macros.html#index-m4_005fsplit-1486) could be the answer, but haven't been able to figure out how to make it work correctly.
Help?
my_var="$1"
my_var=${my_var%%\ *}
my_var=${my_var%%,*}
However, I read at https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Shell-Substitutions.html#Shell-Substitutions that this construct "[does] not work with many traditional shells, e.g., Solaris 10 /bin/sh."
I am at a loss to figure out an acceptable "autoconf portable way" to accomplish this. I suspect some usage of m4_split (https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Text-processing-Macros.html#index-m4_005fsplit-1486) could be the answer, but haven't been able to figure out how to make it work correctly.
Help?