Cygwin:Bash: Preserve '\' in cmdline arg to pass to subshell?

Cygwin:Bash: Preserve '\' in cmdline arg to pass to subshell?

Post by David M. Ka » Sat, 05 Aug 2000 04:00:00



I've been working on Unix for 15 years, and quoting problems still give me a
headache.  It's even worse when I'm working on a script on NT, using Cygwin, as
NT seems delighted to use backslashes as ordinary characters.

I have an "lp" script, which takes a printer name as a command-line parameter,
which will have multiple backslashes in it.  I need to take that exact
parameter and eventually pass it to the DOS "print" command.  This has to
happen without losing any of the backslashes.

Is there a straightforward way to do this, using bash on Cygwin?

 
 
 

Cygwin:Bash: Preserve '\' in cmdline arg to pass to subshell?

Post by 276141.. » Sun, 06 Aug 2000 04:00:00


I'm not sure if this is what you're asking.  But I'm guessing that the
problem isn't the way dos handles the backslash, but the way bash does.
If you want to pass a literal "\" character to dos, you'll have to
escape it in bash first.  So "\\servername\printer" becomes
"\\\servername\\printer".  If it's the other way, and a dos native path
needs to be passed from dos to bash, you're still looking for your
answer. <g>



Quote:> I've been working on Unix for 15 years, and quoting problems still
give me a
> headache.  It's even worse when I'm working on a script on NT, using
Cygwin, as
> NT seems delighted to use backslashes as ordinary characters.
> I have an "lp" script, which takes a printer name as a command-line
parameter,
> which will have multiple backslashes in it.  I need to take that exact
> parameter and eventually pass it to the DOS "print" command.  This has
to
> happen without losing any of the backslashes.

> Is there a straightforward way to do this, using bash on Cygwin?

Sent via Deja.com http://www.deja.com/
Before you buy.