[GRASS-dev] bug in v.db.renamecol [was: Re: [GRASS-user] Rename
multiple sqlite columns at once]
Hamish
hamish_b at yahoo.com
Tue Nov 18 20:49:12 EST 2008
Moritz wrote:
> An easy way around this problem is to modify
> v.db.renamecol:
>
> ---
> SRC/GRASS/grass6_devel/scripts/v.db.renamecol/v.db.renamecol
> 2008-11-06 14:00:04.000000000 +0100
> +++
> SRC/GRASS/grass6_devel/dist.i486-pc-linux-gnu/scripts/v.db.renamecol
> 2008-11-18 14:56:53.000000000 +0100
> @@ -143,8 +143,8 @@
> fi
>
> # describe old col
> -oldcoltype="`db.describe -c table=$table
> database=$database driver=$driver | grep $oldcol | cut
> -d':' -f3`"
> -oldcollength=`db.describe -c table=$table
> database=$database driver=$driver | grep $oldcol | cut
> -d':' -f4`
> +oldcoltype="`db.describe -c table=$table
> database=$database driver=$driver | grep
> $oldcol":" | cut -d':' -f3`"
> +oldcollength=`db.describe -c table=$table
> database=$database driver=$driver | grep
> $oldcol":" | cut -d':' -f4`
>
> This should only grep for the actual column and not any
> supersets of the column name.
[sorry about line wraps, blame yahoo..]
I would suggest like:
oldcoltype="`db.describe -c table="$table" database="$database" driver="$driver" | grep -w "$oldcol" | cut -d':' -f3`"
- always quote variables which could contain spaces (even in error).
- use "grep -w" to only look for words, not strings
alternatively: `grep ": ${oldcol}:"`
Hamish
More information about the grass-dev
mailing list