[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [h-e-w] pb with the use of Merge

From: Nat Goodspeed
Subject: Re: [h-e-w] pb with the use of Merge
Date: Sat, 05 May 2007 17:49:08 -0400

At 05:33 PM 5/5/2007, Eli Zaretskii wrote:

> Typical usage in a bash script:
> cd "$(find-workarea)"
>    I recently had to write a .bat script (don't ask) in which I
> wanted to use the same helper. Here's what I had to write:
> for /f "usebackq" %%w in (`bash find-workarea`) do cd %%w

I don't know what find-workarea does, but there probably are ways to
use the more advanced features of `for /f' for this job without
resorting to backticks, if you just dump the Bash script and do it
straight in cmd.

  Possibly so. I already had the helper script in hand.

The primary intent of `for /f' is to parse files,
so if find-workarea does anything like that, you shouldn't need to
resort to Bash.

Yes. Perhaps it was unnecessarily distracting to illustrate with my specific helper script. The point I was trying to make is this. I very often want a shell script to perform the operation: "run this subcommand and capture its standard output in a variable for later use in the calling script." In earlier versions of the Windows command shell, there was no mechanism for this at all. While I'm pleased that they've added such support, it seems odd to me to graft it onto `for'. As you say, the primary intent of `for' is to loop, and the primary intent of `for /f' is to loop through files. Apologies for rambling so very far afield.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]