This is the mail archive of the
cygwin-talk
mailing list for the cygwin project.
Scripting fun! :-) (was Re: bash scripting nightmare. ( )
- From: Linda Walsh <cygwin at tlinx dot org>
- To: The Cygwin-Talk Maiming List <cygwin-talk at cygwin dot com>
- Date: Thu, 10 Aug 2006 16:12:04 -0700
- Subject: Scripting fun! :-) (was Re: bash scripting nightmare. ( )
- Reply-to: The Cygwin-Talk Maiming List <cygwin-talk at cygwin dot com>
Dave Korn wrote:
Hey all, who's any good at bash scripting?
---
You are doing correctly, mostly. The simplest way to get from
where you are, to where you want to be, is, well think of this:
You have created a "command line" all stuffed into 1 variable, right?
Ala: VAR="cvs co -D \"2006-08-10 15:00:00\" -P pci wimedia"
The value of VAR (putting everything between two vertical bars) is:
|cvs co -D "2006-08-10 15:00:00" -P pci wimedia|
You have a "literal" expression in "VAR", meaning the quotes are stored
as literals and have no special meaning. If you just try to use "execute"
the literal, the arguments are passed in literally.
What you want is for the quotes to regain their special meaning, which
you can do by telling the shell to run it's "eval"uator over the expression
again before executing, as in "eval $VAR". In line 9 of your code below,
just add an "eval" before the argument.
1 #!/bin/bash
2 function runCvsCommand()
3 {
4 # Execute a cvs command, logging appropriately and handling errors.
5 echo "CVS: ${1}"
6
7 # this can take some time
8 echo "(cd .;${1})"
9 (cd .; eval ${1}
10 RET=$?
Linda