Unwanted Shell expansion when assigning the output of a shell command to a variable

Posted by Rob Goodwin on Stack Overflow See other posts from Stack Overflow or by Rob Goodwin
Published on 2010-06-16T18:51:16Z Indexed on 2010/06/16 18:52 UTC
Read the original article Hit count: 318

Filed under:
|
|

I am exporting a portion of a local prototypte svn repository to import into a different repo. We have a number of svn properties set throughout the repo so I figured I would write a script to list the file elements and their corresponding properties. How hard can that be right.

So I write started writing a bash script that would assign the output of the svn proplist -v to a variable so I could check if the specified file had any properties.

#!/bin/bash
svn proplist -v $1
o=$(svn proplist -v "$1")
echo $o

now this works fine and echos the output of the svn proplist command. But if the proplist command returns something like

svn:ignore : * build

it performs a shell expansion on the * and inserts the entire directory listing prior to the build property value. So if the directory had a.txt, b.txt and build files/dirs in it, the output would look like.

svn:ignore a.txt b.txt build

I figure I need to somehow escape the output or something to keep the expansion from happening, but have yet to find something that works. There are other ways to do this, but I hate when I cannot figure something out. and I have to admin, I think this one beat me ( well given the time I can spend on it )

© Stack Overflow or respective owner

Related posts about svn

Related posts about bash