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

Perl replacement challenge


I work in an environment surrounded by KSH users (hey does
this qualify as a "hostile work environment"??). That includes
the system administrators and tool developers, so it is not
surprising there are many scripts in the system which must be
"dotted" into ksh to do something non-trivial and dynamically
setup environment variables as a result.

I have a very simple and effective solution:

	# Use "kshdot some_ksh_script" instead of ". some_ksh_script"

	kshdot() { source =(ksh -c ". $* 1>&2; senv") }

Where 'senv' is the following Perl script:


	# Fixup the output from 'env' so it can be sourced by zsh
	foreach $ev (keys %ENV) {
	  next if $ev eq "_" || $ev eq "PWD";
	  print "export $ev=";
	  $val = $ENV{$ev};
	  $val =~ s/'/'"'"'/g;
	  print "'$val'\n";
Obviously, I'm not happy with having to invoke Perl everytime I
need to source a system script. But since it works, I've left it
as is for several months.

I would appreciate hearing suggestions on how to get rid of Perl,
or other ideas you have for dealing with the root problem (Note:
I don't like to use "emulate -R ksh" in my interactive shells,
it disables too many nice zsh features).

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