Help with variables and new lines, and quoting in a bash script

Posted by Scott on Stack Overflow See other posts from Stack Overflow or by Scott
Published on 2010-06-07T16:27:46Z Indexed on 2010/06/07 16:32 UTC
Read the original article Hit count: 234

Filed under:
|
|

I would like to automate the following svn command. Note this command produces the desired results on my system - Ubuntu 10.04, svn 1.6.6, bash shell, when issued from the command line:

svn ci -m $'Added new File: newFile.txt\nOrig loc: /etc/networking/newFile.txt' /home/user/svnDir/newFile.txt

I would like to run that command in a bash script, assuming that the original full path to the file is contained in the variable $oFileFull, and the filename is in $oFileName. The script is executed from the svn directory. I need to allow for the possibility that the file name and or path contain spaces.

so the line inside my shel script might look like:

svn ci -m$'Added new file: ${oFileName}\nOrig loc: ${oFileFull}' ${oFileName}

But I want the variables (which may contain spaces) expanded before the command is executed, and I cannot figure out how to do this while enclosing the svn comment in single quotes which is necessary in order to get the new line in the subversion comment log. I am pulling my hair out trying to figure out how to properly quote and assemble this command. Any help appreciated.

© Stack Overflow or respective owner

Related posts about bash

Related posts about shell-scripting