Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!batcomputer!pyramid!prls!mips!hansen From: hansen@mips.UUCP (Craig Hansen) Newsgroups: comp.unix.wizards Subject: Re: csh oddity Message-ID: <1326@mips.UUCP> Date: 14 Jan 88 21:14:08 GMT References: <826@murphy.UUCP> <590@devon.UUCP> <1530@ogcvax.UUCP> Lines: 59 In article <1530@ogcvax.UUCP>, schaefer@ogcvax.UUCP (Barton E. Schaefer) writes: > In article hansen@mips.UUCP (Craig Hansen) writes: > >In article <826@murphy.UUCP> dcornutt@murphy.UUCP (Dave Cornutt) writes: > >> I have discovered something peculiar about csh variable substitution. Is > >> this a bug or am I doing something wrong? > > > >You're doing something wrong. The correct syntax is: > > > >% set xy1z={$xy1z}_123 > > Sorry, Craig, that syntax changes the meaning of the {} from "variable > substitution" to "filename substitution" as in > > % set xy1z="one,two,three" > % set xyz={$xy1z}_step > % set > xy1z one,two,three > xyz (one_step two_step three_step) > > The syntax ${xy1z} SHOULD work, but it doesn't (confirmed here for Mt. Xinu > 4.3 BSD csh as well). Does anyone happen to know why it fails? Does it have > anything to do with ${1} being a synonym for $1 (and ${2} for $2 and so on)? OK, OK, it's a bug. I haven't tested the fix, but the following fragment of source file sh.lex.c looks dubious: default: if (digit(c)) { /* * let $?0 pass for now if (special) goto vsyn; */ while (digit(c = getC(DOEXCL))) { if (np < &name[sizeof name / 2]) *np++ = c; } } else if (letter(c)) while (letter(c = getC(DOEXCL))) { if (np < &name[sizeof name / 2]) *np++ = c; } else goto vsyn; Looks like the last call to letter() should be written as: while (letter(c = getC(DOEXCL)) || digit(c)) { There's a macro called alnum(), which would be the obvious replacement, but it evaluates the argument twice :-(. -- Craig Hansen Manager, Architecture Development MIPS Computer Systems, Inc. ...{ames,decwrl,prls}!mips!hansen or hansen@mips.com