Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: maintaining init files on a [t]csh influenced system

On Sep 6,  7:33pm, Zefram wrote:
} Subject: Re: maintaining init files on a [t]csh influenced system
} >On the original question, though -- there are two major syntactic barriers
} >to getting zsh to parse csh script files:
} >
} >1.  "set" commands, because they can do any of:
} >    a.  assign to multiple boolean options in a single command
} >    b.  mix assignments of option variables with string assignments
} >    c.  use spaces around the "=" sign in any string assignment
} >
} >	set noclobber history = 50 nonomatch prompt="`hostname`: "
} >
} >2.  the "$?variable" syntax for testing whether a variable is set
} >
} >You can get zsh to parse just about everything else (*) by clever use of
} >aliases and zsh functions, but I haven't figured out a workaround for
} >either of the above.
} $?variable would have to be supported by zsh itself, and would conflict
} with the normal use of $?.


} I think you could define a set function
} that would do everything required, though.  (Check if argument is an
} option and set it if so, check for separated = signs and join together
} arguments as required.  It's actually not too difficult to write.)

I suspect that if you wrote it, I could break it using something that
would be legal csh syntax.  I do agree that you can cover most of the
common cases.

Oh, I thought of a third serious syntax problem:  History syntax in
aliases.  I shouldn't have forgotten that one, it's even mentioned in
the section that I contributed to the FAQ. :-}

} >(*) "switch" statements are VERY entertaining, but possible (I think);
} >    anybody care to guess how?
} Please enlighten us.

It starts out with something like:

    alias switch='cat >! /tmp/sw$$ <<\endsw ; doswitch'

And finishes up with a doswitch() function that reads the temporary file
and looks for the case ... breaksw block matching the function params.

Bart Schaefer                     Vice President, Technology, Z-Code Software
schaefer@xxxxxxxxxx                  Division of NCD Software Corporation

Messages sorted by: Reverse Date, Date, Thread, Author