[comp.unix.shell] : t modifier in tcsh and csh

mgemmel@cs.vu.nl (Martin Gemmel) (06/12/91)

I have a script, called bin/script, which looks like:
echo $0:t

Doing  'csh -f bin/script' yields: 'bin/script:t'
Doing 'tcsh -f bin/script' (correctly) yields: 'script'

Csh clearly doesn't do the Right Thing, but why?
(tcsh is version 5.18)

Martin
--
Uhm... Martin Gemmel

wallace@ynotme.enet.dec.com (Ray Wallace) (06/13/91)

In article <10186@star.cs.vu.nl>, mgemmel@cs.vu.nl (Martin Gemmel) writes...
>Doing  'csh -f bin/script' yields: 'bin/script:t'
In csh you can not use the : modifiers on the positional variables. You will
need to assign $0 to another variable and then use :t on that new variable.

---
Ray Wallace		
		(INTERNET,UUCP) wallace@oldtmr.enet.dec.com
		(UUCP)		...!decwrl!oldtmr.enet!wallace
		(INTERNET)	wallace%oldtmr.enet@decwrl.dec.com
---

mday@icon.com (Matt Day) (06/13/91)

In article <10186@star.cs.vu.nl> mgemmel@cs.vu.nl (Martin Gemmel) writes:
>I have a script, called bin/script, which looks like:
>echo $0:t
>
>Doing  'csh -f bin/script' yields: 'bin/script:t'
>Doing 'tcsh -f bin/script' (correctly) yields: 'script'
>
>Csh clearly doesn't do the Right Thing, but why?
>(tcsh is version 5.18)

Looks like yet another csh bug, one that isn't fixed in Tahoe 4.3BSD.  If
you want the hundreds of dinky csh bugs like this to go away, plus lots of
nice extensions, then use tcsh (FTP from tesla.ee.cornell.edu).
-- 
- Matt Day, Sanyo Icon R&D, mday@icon.com

mday@icon.com (Matt Day) (06/13/91)

In article <1991Jun12.204347.2932@engage.pko.dec.com> wallace@ynotme.enet.dec.com (Ray Wallace) writes:
>In csh you can not use the : modifiers on the positional variables. You will
>need to assign $0 to another variable and then use :t on that new variable.

The problem only affects $0, not the other parameter variables.  You should
be able to use the modifiers on any variable -- it is a stupid bug.  Under
the csh, variable modifiers do not work on environment variables either;
this bug is also fixed in the tcsh.
-- 
- Matt Day, Sanyo Icon R&D, mday@icon.com

jmason2@gpu.utcs.utoronto.ca (Jamie Mason) (06/13/91)

In article <1991Jun12.204347.2932@engage.pko.dec.com> wallace@ynotme.enet.dec.com (Ray Wallace) writes:
>
>In csh you can not use the : modifiers on the positional variables. You will
>need to assign $0 to another variable and then use :t on that new variable.

	Actually, you *can* use the : modifiers on positional varaibles.
Just not on $0.  This is a bug, and an obnoxioius one at that.  (Since $0 
tends to inculde a full path from the sematics of '#!', and so tends to
be the positional parameter you are *most* likely to want to ':t'.

Jamie  ...  Segmentation fault (core dumped)
Written On  Wednesday, June 12, 1991  at  10:46:09pm EDT