Opened 16 years ago
Closed 16 years ago
#81 closed defect (fixed)
scripts: "echo -n" not portable
| Reported by: | hamish | Owned by: | hamish |
|---|---|---|---|
| Priority: | blocker | Milestone: | 6.3.0 |
| Component: | Default | Version: | svn-trunk |
| Keywords: | Cc: | grass-dev@… | |
| CPU: | Unspecified | Platform: | Unspecified |
Description
Hi,
apparently "echo -n" is not portable, it fails on OSX 10.5
I removed it from scripts/r.in.wms/wms.request, but these remain:
scripts$ grep -rIl "echo -n" * | grep -v '/.svn/' d.vect.thematic/d.vect.thematic i.in.spotvgt/i.in.spotvgt r.tileset/r.tileset v.db.renamecol/v.db.renamecol
v.db.renamecol is a false positive:
v.db.renamecol/v.db.renamecol: # 'echo -n' (output as string, ie with no newline) is apparently not portable.
Hamish
Change History (7)
comment:1 by , 16 years ago
| Cc: | added |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
comment:2 by , 16 years ago
comment:3 by , 16 years ago
d.vect.thematic and i.in.spotvgt are updated in SVN/trunk, if someone who uses those could test please? then we can backport for 6.3.0.
I am not sure about r.tileset:
Index: r.tileset/r.tileset
===================================================================
--- r.tileset/r.tileset (revision 30465)
+++ r.tileset/r.tileset (working copy)
@@ -189,15 +189,11 @@
Lookup_Mac() {
# Assignment Command Statement Builder
+# $1 is Source name
+# $3 is Destination name
- echo -n 'eval '
- echo -n "$3" # Destination name
- echo -n '=${'
- echo -n "$1" # Source name
- echo -n "[$2]}"
+ echo "eval $3=${$1[$2]}"
-# That could all be a single command.
-# Matter of style only.
}
# Lookup_Mac
?will that work?
newline suppression via printf shouldn't be needed....
Hamish
comment:4 by , 16 years ago
Glynn wrote:
I wouldn't count on it; the shell may attempt to evaluate the ${...} part.
I suspect that may be why it was output in pieces in the first place.
Try:
echo 'eval '"$3"'=${'"$1""[$2]}"
I glazed over last time I tried to follow that, not realizing that it is just a straight concatenation of the series of 'echo -n' lines. So no less safe than what is currently there.
Paul also suggested using GRASS's own $GISBASE/etc/echo which respects -n, which could be clearer but doesn't help us ween ourselves off of workaround apps.
I am currently leaning towards Glynn's suggestion as it requires a smaller toolset.
I had guessed that in OSX 10.5 /bin/echo did not like -n but the bash shell was ok with it (and so !/bin/bash'ing r.tileset apparently worked without modification). Rereading William's comment in this bug report suggests the opposite it true. Best to just get rid of the -n rather than spend time trying to work out why..
Hamish
comment:5 by , 16 years ago
'echo -n' removed from r.tileset in r30616.
d.vect.thematic, i.in.spotvgt, and r.tileset (r.in.wms) now need testing in trunk before backporting them to the 6.3.0 branch and closing this bug.
Hamish
comment:6 by , 16 years ago
I have tested i.in.spotvgt, it works. Backported to 6.3.0-relbranch as [c30621].
Markus

If using echo without -n doesn't work for some reason, I found that/bin/echo on OSX 10.5 DOES work, it's the shell version of echo on 10.5 that doesn't have -n.
The echo man page suggests using printf to suppress the newline char, for portability.