[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: POSIX replacement for bash's “export -n” ?



Charles Plessy wrote:

Hello everybody,

In one of the packages I maintain, building fails when the default shell is
/bin/dash because of an “export -n” command that was not found by checkbashisms
(probably because it was hidden in a Perl script).

I would like to send a patch Upstream, but have not found a drop-in replacement
for this command, apart from someghing ugly like:

BAR=$FOO ; unset FOO ; FOO=$BAR ; unset BAR

to replace ‘export -n FOO’.

Any idea ?

Have a nice day,



There really doesn't seem to be a way. I can only suggest:

* bolt those comands up into an "unexport" function (not pretty;
  make your "BAR" local and you don't need to subsequently
  unset it)

* perhaps you can run the commands needing the exported variable
  in a subshell? (see under "Grouping Commands Together" in the
  man page). If you export anything in a subshell, it won't be
  reflected in the "main" shell, but beware, nor will any other
  shell builtin take effect. (Potentially also not pretty, and/or
  a lot of work rewriting)

HTH, or you get a better suggestion ;)

--
Chris Jackson
Shadowcat Systems Ltd.



Reply to: