mostek@motcid.UUCP (Frank B. Mostek) (04/26/91)
I am having a problem with the csh setenv command: $setenv EXINIT `cat ~/.myexrc` `cat ~/.myexrc`: Ambiguous. Any ideas? I am setting EXINIT to prevent vi from invoking the .exrc file twice when I invoke vi from my home directory. This causes some bad side effects. Thanx in advance. -- Frank Mostek uunet!motcid!amethyst!mostek (708)632-7191 mostek@amethyst.mot.com
paul@falstad (04/26/91)
mostek@motcid.UUCP (Frank B. Mostek) wrote: >I am having a problem with the csh setenv command: > >$setenv EXINIT `cat ~/.myexrc` >`cat ~/.myexrc`: Ambiguous. The problem is that `cat ~/.myexrc` produces more than one word. setenv takes only two arguments. Do: setenv EXINIT "`cat ~/.myexrc`" The double quotes prevent the `...` from being split into words. -- Paul Falstad pfalstad@phoenix.princeton.edu And on the roads, too, vicious gangs of KEEP LEFT signs! If Princeton knew my opinions, they'd have expelled me long ago.
hansm@cs.kun.nl (Hans Mulder) (04/26/91)
In <6291@beryl12.UUCP> mostek@motcid.UUCP (Frank B. Mostek) writes: >I am having a problem with the csh setenv command: >$setenv EXINIT `cat ~/.myexrc` >`cat ~/.myexrc`: Ambiguous. >Any ideas? setenv EXINIT "`cat ~/.myexrc`" -- Have a nice day, Hans Mulder hansm@cs.kun.nl
subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (04/26/91)
In article <56092@notavax.Princeton.EDU> writes: >mostek@motcid.UUCP (Frank B. Mostek) wrote: >>I am having a problem with the csh setenv command: >> >>$setenv EXINIT `cat ~/.myexrc` >>`cat ~/.myexrc`: Ambiguous. > >The problem is that `cat ~/.myexrc` produces more than one word. setenv >takes only two arguments. Do: > >setenv EXINIT "`cat ~/.myexrc`" > >The double quotes prevent the `...` from being split into words. > Unfortunately, this doesn't work in csh (like it does in another unmentioned shell :-) ). You can do this, but it depends upon the format of your .exrc: % setenv EXINIT "`tr -d \\012 < ~/.ex`" Since you can't quote newlines in csh (apparently). Your .exrc should not have multiple set statements, because the whole .exrc has to be slurped in as one line. I don't know about putting comments in either; they may screw things up. But anyway, you said that the reason that you used this setenv approach is because the .exrc got executed twice? Are you sure? I have a .exrc in my home directory and it never gets executed twice when I vi stuff (e.g, this ~/.article file I'm editing now). You might want to tell us your setup so that there might be an easier way to do this. -Kartik -- internet# rm `df | tail +2 | awk '{ printf "%s/quotas\n",$6}'` subbarao@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet
weimer@garden.ssd.kodak.com (Gary Weimer (253-7796)) (04/27/91)
In article <6291@beryl12.UUCP>, mostek@motcid.UUCP (Frank B. Mostek) writes: |> I am having a problem with the csh setenv command: |> |> $setenv EXINIT `cat ~/.myexrc` |> `cat ~/.myexrc`: Ambiguous. |> |> Any ideas? who about: set x=(`awk '{if(substr($1,1,1)=="\"")next}{if(s==""){s=$0}else{s=s"|"$0}}END{print s}' ~/.myexrc`) setenv EXINIT "$x" This makes the necessary formatting changes, skipping comments (awk script) and gets rid of Ambiguous error (`cat ~/.myexrc` produces multiple "words", setenv interprets them as multiple params and gags). NOTE: setenv EXINIT "`awk '<program>' ~/.myexrc`" would be nice, but I couldn't get it to work; hence the intermediate set x=(...) weimer@ssd.kodak.com ( Gary Weimer )
chap@art-sy.detroit.mi.us (j chapman flack) (04/30/91)
In article <6291@beryl12.UUCP> mostek@motcid.UUCP (Frank B. Mostek) writes: >I am having a problem with the csh setenv command: > >$setenv EXINIT `cat ~/.myexrc` >`cat ~/.myexrc`: Ambiguous. > Phooey. I'd never realized something could be so difficult in csh. According to `man csh' (which doesn't have a single word about the `Ambiguous' diagnostic, at least in my SCO SysV version), the result of a `command substitution` is the output of the command, with all whitespace, including newlines, turned into word delimiters--so even if the `stuff` *did* work, you would wind up with multiple words, which would make setenv complain, because the value is supposed to be a string in the form of one word. Putting the `command substitution` in "double quotes" changes things slightly--now it only changes newlines into word delimiters, leaving blanks and tabs untouched. That still winds up giving you multiple words if you have multiple lines. You can assign it to a variable first: % set exinit=( "`cat ~/.myexrc`" ) % setenv EXINIT "$exinit" and you won't get any complaints, but the EXINIT string won't have any newlines in it where your lines are supposed to break, an ex probably won't like that. Moral: `command substitution` in csh is fundamentally different than in sh. That observation led me to try the following, and it works fine. Just don't tell me it's ugly. I know it's ugly. In fact, if you say it was my idea I'll deny it. :-) (I'd welcome a better idea!) if ! ${?EXINIT} exec sh -c 'export EXINIT;EXINIT=`cat ${HOME}/myexrc`;exec csh' (Yuck.) The test, of course, is needed to prevent an infinite loop. Here's hoping you find a better idea and don't have to use this! -- Chap Flack Their tanks will rust. Our songs will last. chap@art-sy.detroit.mi.us -Mikos Theodorakis Nothing I say represents Appropriate Roles for Technology unless I say it does.
daniel@island.COM (Daniel Smith "innovation, not litigation...") (05/03/91)
In <9104292045.aa10390@art-sy.detroit.mi.us> chap@art-sy.detroit.mi.us (j chapman flack) writes: > In article <6291@beryl12.UUCP> mostek@motcid.UUCP (Frank B. Mostek) writes: > if ! ${?EXINIT} exec sh -c 'export EXINIT;EXINIT=`cat ${HOME}/myexrc`;exec csh' This works fine for me... setenv EXINIT "so $HOME/.exrc" Daniel -- daniel@island.com Daniel Smith, Island Graphics, (415) 491 0765 x 250(w) daniel@world.std.com 4000 CivicCenterDrive SanRafael MarinCounty CA 94903 dansmith@well.sf.ca.us Fax: 491 0402 Disclaimer: Hey, I wrote it, not IG! falling/yes I'm falling/and she keeps calling/me back again - IJSaF, Beatles