RE: Recommended way to truncate a shell variable value in autoconf

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

 



Eric Blake said:
> ....  Just go with:
> X=`echo "$X" | sed 's/[, ].*//'`

The "sed" is nice and clear.

However, that "echo" will probably cause trouble if $X starts with "-" or has other characters in it.
I presume in this case that $X will *usually* start with "-", so you REALLY don't want to use echo directly.
Unless $X can *only* contain alphanumerics, I suggest replacing echo "$X" with:
 printf '%s\n' "$X"
An alternative would be to use AS_ECHO.

Dale Visser, you might want to look here:
 https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Portable-Shell.html
and especially:
 https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Limitations-of-Builtins.html

--- David A. Wheeler

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux