Path: utzoo!attcan!uunet!husc6!think!ames!lll-tis!helios.ee.lbl.gov!nosc!ucsd!ucsdhub!hp-sdd!hplabs!otter!pdc From: pdc@otter.hple.hp.com (Damian Cugley) Newsgroups: comp.unix.questions Subject: Re: CSH Help -- I don't get it ... Message-ID: <1170005@otter.hple.hp.com> Date: 16 Aug 88 11:32:37 GMT References: <9832@eddie.MIT.EDU> Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 81 / comp.unix.questions / greim@sbsvax.UUCP (Michael Greim) / Aug 12, 1988 / Quickly dispose of the basenote topic before getting on with the drift :-) > > It may not be a bug. > Yes, this may not be a bug. > ^^^^ > (So nobody needs a fix, nobody has to work one out, and > all versions of csh behave the same :-) Agree! Agree! :-D > The bug fix I mentioned above was for another but similar problem > [...See Michael's posting for details!...] > The above cited fix was for this problem. Afterwards > % ls a{b,\,}c produced the correct output : > a,c abc I would also have expected '\,' to work, using the same logic as before. > [Csh] expands other operands. Try : > if ( Gargle* =~ "Gargle"*) then > [...] > and you will see, that csh filename expands the left operand of "=~". By gum, so it does. Wild. (I guess the csh designers would reply as the left operand of =~ isn't supposed to be a pattern, it can anly be expected to act weirdly if it is... I dunno what I'd've done, maybe an error message ('Pattern on left of =~'), or maybe treat the '*' as unmagical?) I would suspect the csh programmers never considered that these situations would occur often, and didn't bother making csh react to them sensibly... > BTW: > And why is the pattern not command substituted? Does the manual say > so? Should it not be possible to > if ( "$a" =~ *`hostname`*) ... > whereas > if ( "$a" == `hostname` ) ... > works ?? Ummm... Errmmm... well, the csh man page says command substitution comes before filename expansion, but not where =~ patterns come in (it should do, though). I guess the designers of csh thought something like if ($wombat =~ `cmd file.*`) would be more useful more often than having patterns outside the `...`. (As a user of csh (as opposed to a programmer of csh) I'd've expected the filenames in `...` to be expanded, *then* the command executed, *then* the patterns involving the output of the command. This would make both of these work - but would need two separate stages of pattern-checking (or three?) and would be even more complicated.) > The manual should be extended to say some lines about patterns in > csh expressions. > One can adapt to a lot of strange rules if they are documented. > > -mg I agree 1000%. Just having a summary of the order of the various stages would help in these sorts of questions. The problem is the csh 'page' is already too long for the way it is now - I had a terrible time ploughing through it for the first time. It's a big enough topic to warrant its own mini-glossary, ToC and/or index. (Or maybe hypertexed like the Emacs info pages? Then each section could have a summary of how X-substitution interacts with Y-substitution without the manual seeming repetative.) Anyone like to volunteer to re-write the entire manual? Just a thought :-) . pdc -- /--Damian Cugley---\/---------------------------------------\/----------------\ | St Edmund Hall || UKNet:|| 'His feet are | | OXFORD || Other- pdc@hplb.lb.hp.co.uk (Until || the wrong size | | U.K. OX1 4AR || net:(?)/---------------------\ Oct) || for his shoes.'| \------------------/\--------/ #disclaim \------/\----------------/