configure echo usage
I'm new to the list, so please let me know if this isn't the way to go about this:
/bin/sh on my system (OS X 10.5.x) invokes a shell which has a built-in echo command which doesn't have a "-n" option. Subseqently the config output files don't get comments where they should. The following patch should provide the same functionality.
thanks,
-lev
------
bash-3.2$ svn diff configure
configure (working copy) renamed from configure (revision 6069) +0 -0
@@ -1094,8 +1094,7 @@ test -f $config_h && mv $config_h ${config_h}~ echo "# Automatically generated by configure - do not modify" >
$config_mak
-echo -n "# Configured with:" >> $config_mak
-printf " '%s'" "$0" "$@" >> $config_mak
+printf "# Configured with: $0 $@" >> $config_mak
echo >> $config_mak
echo "/* Automatically generated by configure - do not modify */" >
$config_h
Quoted 16 lines · Lev Lvovsky
bash-3.2$ svn diff configure
Index: configure
===================================================================configure (working copy) renamed from configure (revision 6069) +0
-0@@ -1094,8 +1094,7 @@ test -f $config_h && mv $config_h ${config_h}~ echo "# Automatically generated by configure - do not modify" >$config_mak
configure (working copy) renamed from configure (revision 6069) +1
-2-echo -n "# Configured with:" >> $config_mak -printf " '%s'" "$0" "$@" >> $config_mak +printf "# Configured with: $0 $@" >> $config_mak echo >> $config_mak echo "/* Automatically generated by configure - do not modify */" >
Quoted 4 lines
$config_h
That doesn't give the same output: the original puts each of $0 and the $@'s with single quotes around them in the config file, yours misses out the quotes. Replacing the original echo -n, printf and echo like this would work though:
echo "# Configured with:$(printf " '%s'" "$0" "$@")" >> $config_mak
If the OS X shell doesn't do $(...) then this will work, albeit at the cost of readabilty
echo "# Configured with:"printf " '%s'" "$0" "$@" >> $config_mak
(those pesky backquotes are harder to see and for the ultra-picky it's not quite the same thing).
jch
Quoted 1 line · John Haxby
echo "# Configured with:$(printf " '%s'" "$0" "$@")" >> $config_mak
You don't need echo if you have printf.
{ printf "# Configured with:"
printf " '%s'" "$0" "$@"
} >> $config_makAndreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 13 lines · Andreas Schwab
Quoted 2 lines · John Haxby
echo "# Configured with:$(printf " '%s'" "$0" "$@")" >> $config_makYou don't need echo if you have printf.
{ printf "# Configured with:" printf " '%s'" "$0" "$@" } >> $config_mak
You're missing a new line :-) Seriously though, there are any number of ways to do the job, some longer and more obscure than others. If you don't have printf and echo -n you can still do it:
echo $(echo "# Configured with:"; for i in "$0" "$@"; do echo "'$i'";
done)
and there are ways of using 'tr -d' as well. And, I'm sure, many others. We should have a Holiday Competition for the most obscure :-)
jch
Quoted 4 lines · John Haxby
That doesn't give the same output: the original puts each of $0 and the $@'s with single quotes around them in the config file, yours misses out the quotes. Replacing the original echo -n, printf and echo like this would work though:
echo "# Configured with:$(printf " '%s'" "$0" "$@")" >> $config_mak
The above works as intended.
Quoted 3 lines
If the OS X shell doesn't do $(...) then this will work, albeit at the cost of readabilty
echo "# Configured with:"
printf " '%s'" "$0" "$@">> $config_mak
This works too.
Typically how do these patches get absorbed into the source?
thanks!
-lev
The reason why /bin/sh's echo doesn't work is because it's working in legacy mode: http://developer.apple.com/releasenotes/Darwin/RN-Unix03Conformance/
Maybe changing the shell that processes it to /bin/bash?
Quoted 21 lines · Lev Lvovsky
Quoted 4 lines · John Haxby
That doesn't give the same output: the original puts each of $0 and the $@'s with single quotes around them in the config file, yours misses out the quotes. Replacing the original echo -n, printf and echo like this would work though:
echo "# Configured with:$(printf " '%s'" "$0" "$@")" >> $config_mak
The above works as intended.
Quoted 3 lines
If the OS X shell doesn't do $(...) then this will work, albeit at the cost of readabilty
echo "# Configured with:"
printf " '%s'" "$0" "$@">> $config_makThis works too.
Typically how do these patches get absorbed into the source?
thanks!
-lev
C.W.,
Quoted 2 lines · C.W. Betts
The reason why /bin/sh's echo doesn't work is because it's working in legacy mode: http://developer.apple.com/releasenotes/Darwin/RN-Unix03Conformance/
Maybe changing the shell that processes it to/bin/bash?
By that, do you mean the ! line at the top, or changing it on my system end? I figured that that might break more than just what I had intended.
thanks,
-lev