autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Recommended way to truncate a shell variable value in autoconf


From: Dale Visser
Subject: Recommended way to truncate a shell variable value in autoconf
Date: Fri, 21 Feb 2014 17:08:02 -0500

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?
                                          

reply via email to

[Prev in Thread] Current Thread [Next in Thread]