public inbox for cygwin-talk@cygwin.com
 help / color / mirror / Atom feed
* Scripting fun! :-) (was Re: bash scripting nightmare. ( )
@ 2006-08-10 23:12 Linda Walsh
  2006-08-11  1:19 ` Dave Korn
  0 siblings, 1 reply; 5+ messages in thread
From: Linda Walsh @ 2006-08-10 23:12 UTC (permalink / raw)
  To: The Cygwin-Talk Maiming List

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Scripting fun! :-) (was Re: bash scripting nightmare. ( )
  2006-08-10 23:12 Scripting fun! :-) (was Re: bash scripting nightmare. ( ) Linda Walsh
@ 2006-08-11  1:19 ` Dave Korn
  2006-08-11 15:14   ` Igor Peshansky
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Korn @ 2006-08-11  1:19 UTC (permalink / raw)
  To: 'hooray!'

On 11 August 2006 00:12, Linda Walsh wrote:

> 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.

  Thankyou thankyou thank you THANK YOU!

  That made it all seem so clear.  I could see that the quote mark was getting attached to the first word and not keeping the two words as one arg, but I didn't know what it means or what to do with it.  Eval'ing it worked perfectly, just like you said.  Thanks for saving my sanity!

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Scripting fun! :-) (was Re: bash scripting nightmare. ( )
  2006-08-11  1:19 ` Dave Korn
@ 2006-08-11 15:14   ` Igor Peshansky
  2006-08-11 15:41     ` Dave Korn
  0 siblings, 1 reply; 5+ messages in thread
From: Igor Peshansky @ 2006-08-11 15:14 UTC (permalink / raw)
  To: The Cygwin-Talk Maiming List

On Fri, 11 Aug 2006, Dave Korn wrote:

> On 11 August 2006 00:12, Linda Walsh wrote:
>
> > 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.
>
>   Thankyou thankyou thank you THANK YOU!
>
>   That made it all seem so clear.  I could see that the quote mark was
> getting attached to the first word and not keeping the two words as one
> arg, but I didn't know what it means or what to do with it.  Eval'ing it
> worked perfectly, just like you said.  Thanks for saving my sanity!

Not to sound defensive, but did you happen to see
<http://cygwin.com/ml/cygwin-talk/2006-q3/msg00138.html> from yesterday?
Just curious...
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha@cs.nyu.edu | igor@watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Scripting fun! :-) (was Re: bash scripting nightmare. ( )
  2006-08-11 15:14   ` Igor Peshansky
@ 2006-08-11 15:41     ` Dave Korn
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Korn @ 2006-08-11 15:41 UTC (permalink / raw)
  To: '${Maiming\ List["The Cygwin-Talk"]}'

On 11 August 2006 16:14, Igor Peshansky wrote:

> On Fri, 11 Aug 2006, Dave Korn wrote:
> 
>> On 11 August 2006 00:12, Linda Walsh wrote:
>> 
>>> 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.
>> 
>>   Thankyou thankyou thank you THANK YOU!
>> 
>>   That made it all seem so clear.  I could see that the quote mark was
>> getting attached to the first word and not keeping the two words as one
>> arg, but I didn't know what it means or what to do with it.  Eval'ing it
>> worked perfectly, just like you said.  Thanks for saving my sanity!
> 
> Not to sound defensive, but did you happen to see
> <http://cygwin.com/ml/cygwin-talk/2006-q3/msg00138.html> from yesterday?
> Just curious...
> 	Igor

  Yep, but I was reading my mail out-of-order.  However, just to show there's
no favouritism going on here,

Thankyou thankyou thank you THANK YOU IGOR!

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Scripting fun! :-) (was Re: bash scripting nightmare. ( )
  2006-08-10 17:54 bash scripting nightmare Dave Korn
@ 2006-08-10 23:10 ` Linda A. Walsh
  0 siblings, 0 replies; 5+ messages in thread
From: Linda A. Walsh @ 2006-08-10 23:10 UTC (permalink / raw)
  To: The Cygwin-Talk Maiming List

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-08-11 15:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-10 23:12 Scripting fun! :-) (was Re: bash scripting nightmare. ( ) Linda Walsh
2006-08-11  1:19 ` Dave Korn
2006-08-11 15:14   ` Igor Peshansky
2006-08-11 15:41     ` Dave Korn
  -- strict thread matches above, loose matches on Subject: below --
2006-08-10 17:54 bash scripting nightmare Dave Korn
2006-08-10 23:10 ` Scripting fun! :-) (was Re: bash scripting nightmare. ( ) Linda A. Walsh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).