[GRASS-dev] Re: [GRASS-SVN] r30420 - grass/trunk/scripts/v.db.renamecol

Hamish hamish_b at yahoo.com
Sun Mar 2 12:57:24 EST 2008


Maciej Sieczka wrote:
> >>  New Revision: 30420
> >>
> >>  Modified:
> >>    grass/trunk/scripts/v.db.renamecol/v.db.renamecol
> >>  Log:
> >>  Fix: protect key column, allow renaming 'cat' when it isn't a key
> >>  column.
> >>  Get rid of awk dependency.
> >>  Minor fixes.
Markus:
> > are you sure that this is portable?
> > 
> > if [ "$driver" = "dbf" ] ; then
> > -  NAMELEN=`echo "$newcol" | wc -c | awk '{print $1}'`
> > +  NAMELEN=`echo "$newcol" | wc -c`
> > 
> > I darkly remember that some "wc" programs insert odd spaces which
> > would break the script.
> 
> I haven't heard of it. Maybe you are right. Let's ask on the dev ML. 
> Thoughts, Anybody?

'wc -c filename' will produce output like: '17 filename' (needing awk
or cut) while 'wc -c < filename' or 'cat filename | wc -c' will produce
output like: '17'. Maybe that is the dark memory?

For curiosity, what's so bad about using awk? speed? It cannot be
removed from all scripts* so why remove from any?  [*] needed for FP
math (and less hard to find than bc), fancy stuff like v.in.mapgen, ...



 #### setup temporary file
 TMP="`g.tempfile pid=$$`"
 if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
-    g.message -e "Unable to create temporary files" 
+    g.message -e "Unable to create temporary files."
     exit 1
 fi


IIUC the message standardization has been to not end single sentence
warnings and errors with a ".", only to do that with module
descriptions. (I don't know if I agree with that all the time, but a
lot of effort has gone in to making it that way)


 if [ -z "$table" ] ; then
-   g.message 'There is no table connected to this map! Cannot rename
any column.'
+   g.message -e "There is no table connected to input vector map!
Cannot rename any column."
    cleanup
    exit 1
 fi

and r30418: v.db.dropcol
@@ -91,5 +80,5 @@
 exitprocedure()
 {
- g.message -e 'User break!'
+ g.message -e "User break!"
  cleanup
  exit 1


"!" is a special shell char and must be quoted in 'single quotes'.

GRASS> g.message -e "this will not work!, ok?"
bash: !,: event not found



Hamish



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs



More information about the grass-dev mailing list