any shell that doesn't expand \t or \n in it's arguments?

any shell that doesn't expand \t or \n in it's arguments?

Post by jwk » Wed, 31 Mar 2004 20:36:48



I have a program that calls a script to print files, both on windows and
on unix systems.

Because of the windows systems, one argument to the script is like this:

\\host\queue

Depending on the name of queue, this makes the script on unix go
haywire:

\x is '\' 'x', but \t becomes '<tab>'

is there any way to start a shell which prevents this horrible mess?
The only alternative is to rename all my print-queues :-(

Thanks,
Jurriaan

--
The language of the Oracle is Truth, and his accent is ASCII.
        The USENET Oracle
Debian (Unstable) GNU/Linux 2.6.5-rc2-mm5 2x5947 bogomips 0.29 0.30

 
 
 

any shell that doesn't expand \t or \n in it's arguments?

Post by Barry Margoli » Wed, 31 Mar 2004 23:31:17




> I have a program that calls a script to print files, both on windows and
> on unix systems.

> Because of the windows systems, one argument to the script is like this:

> \\host\queue

> Depending on the name of queue, this makes the script on unix go
> haywire:

> \x is '\' 'x', but \t becomes '<tab>'

> is there any way to start a shell which prevents this horrible mess?
> The only alternative is to rename all my print-queues :-(

AFAIK, none of the common shells automatically translate \t and \n.  If
any translation is done, it's by individual commands, e.g. "echo".  They
generally provide a way to suppress it, or you must escape the
backslashes (e.g. change \t to \\t before passing the string to the
command).

If you show the script, perhaps we can provide more detailed guidance.

--

Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

 
 
 

any shell that doesn't expand \t or \n in it's arguments?

Post by jwk » Thu, 01 Apr 2004 02:43:58



Date: Tue, 30 Mar 2004 09:31:17 -0500


>> I have a program that calls a script to print files, both on windows and
>> on unix systems.

>> Because of the windows systems, one argument to the script is like this:

>> \\host\queue

>> Depending on the name of queue, this makes the script on unix go
>> haywire:

>> \x is '\' 'x', but \t becomes '<tab>'

>> is there any way to start a shell which prevents this horrible mess?
>> The only alternative is to rename all my print-queues :-(

> AFAIK, none of the common shells automatically translate \t and \n.  If
> any translation is done, it's by individual commands, e.g. "echo".  They
> generally provide a way to suppress it, or you must escape the
> backslashes (e.g. change \t to \\t before passing the string to the
> command).

> If you show the script, perhaps we can provide more detailed guidance.

Aha - it's echo then. The faulty part is something like this:

host=`echo $1 | cut -d"\\" -f1`
queue=`echo $1 | cut -d"\\" -f2`

Time to go play with bash and ${param:offset:length}.

Thanks,
Jurriaan
--
I've seen people with new children before, they go from ultra happy to
looking like something out of a zombie film in about a week.
        Alan Cox about Linus after his 2nd daughter
Debian (Unstable) GNU/Linux 2.6.5-rc2-mm5 2x5947 bogomips 0.15 0.23

 
 
 

any shell that doesn't expand \t or \n in it's arguments?

Post by Barry Margoli » Thu, 01 Apr 2004 04:19:16




> Aha - it's echo then. The faulty part is something like this:

> host=`echo $1 | cut -d"\\" -f1`
> queue=`echo $1 | cut -d"\\" -f2`

> Time to go play with bash and ${param:offset:length}.

Or use printf:

host=$(printf '%s' "$1" | cut -d'\\' -f1)

--

Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

 
 
 

any shell that doesn't expand \t or \n in it's arguments?

Post by Chris F.A. Johnso » Thu, 01 Apr 2004 04:30:45




> Date: Tue, 30 Mar 2004 09:31:17 -0500


>>> I have a program that calls a script to print files, both on windows and
>>> on unix systems.

>>> Because of the windows systems, one argument to the script is like this:

>>> \\host\queue

>>> Depending on the name of queue, this makes the script on unix go
>>> haywire:

>>> \x is '\' 'x', but \t becomes '<tab>'

>>> is there any way to start a shell which prevents this horrible mess?
>>> The only alternative is to rename all my print-queues :-(

>> AFAIK, none of the common shells automatically translate \t and \n.  If
>> any translation is done, it's by individual commands, e.g. "echo".  They
>> generally provide a way to suppress it, or you must escape the
>> backslashes (e.g. change \t to \\t before passing the string to the
>> command).

>> If you show the script, perhaps we can provide more detailed guidance.

> Aha - it's echo then. The faulty part is something like this:

> host=`echo $1 | cut -d"\\" -f1`
> queue=`echo $1 | cut -d"\\" -f2`

   There's no need for an external command:

oldIFS=$IFS

IFS='\'
set -- $1
host=$1
queue=$2

IFS=$oldIFS

Quote:> Time to go play with bash and ${param:offset:length}.

--
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License
 
 
 

any shell that doesn't expand \t or \n in it's arguments?

Post by jwk » Fri, 02 Apr 2004 01:40:57



Date: Tue, 30 Mar 2004 14:19:16 -0500


>> host=`echo $1 | cut -d"\\" -f1`

> Or use printf:

> host=$(printf '%s' "$1" | cut -d'\\' -f1)

That solved it. Thanks,

Jurriaan
--
If it wasn't for C, we would be using BASI, PASAL and OBOL!
Debian (Unstable) GNU/Linux 2.6.5-rc2-mm5 2x5947 bogomips 0.34 0.28

 
 
 

1. ``M-x shell'' command under emacs doesn't quite work.

I can almost get ``M-x shell'' to work under GNU emacs, but I always get
the following error message:

        /bin/bash: [257: 2] tcgetattr: EINVAL

I have only three questions:  What is ``EINVAL,'' what is ``tcgetattr''
and what does the [257: 2] represent.  And, I guess a forth question:
has any found a work-around.  

I'm using the binaries from tsx-11, and the 0.95a kernel with ps added.
Is the problem in the kernel? in emacs? in Bash?

I also notice that after suspending emacs and resuming it with ``fg''
the tty is no longer in cbreak mode.  I suppose this is a problem with
Bash?  

Thanks in advance for any help.

-Joel

2. How to use int mount() and int umount() ???

3. 'more' doesn't work with non-login shells

4. Configuring ISA-PnP modem

5. What's 'side effects' of Ksh built-ins?

6. dbm for Linux ?

7. Taking arguments from pipe 'plus' one more argument

8. Linux 1.1.52 and Printing?

9. IP Accounting doesn't work for PPP dial-ins :-(( ??

10. su doesn't read user's shell init files?

11. I changed root's shell and doesn't login as root

12. `set -A junk' doesn't work in Korn Shell?

13. ping -g 'gateway-IP' 'host-IP' DOESN'T work!