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

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



On Mon, Jul 12, 2010 at 08:56:55PM +0900, Charles Plessy wrote:
> Le Mon, Jul 12, 2010 at 08:56:25AM +0100, Chris Jackson a écrit :
> >>
> >> 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’.
> 
> > * 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)
> 
> Thanks a lot for the suggestion! In my particular case, I think that it does
> what is intended. I will replace the following line of the Perl script that
> causes problem with dash:
> 
>   open (WOSSNAME, "export -n EMBOSS_ACDCOMMANDLINE;wossname -alpha -auto|") || die "Cannot run wossname";
> 
> by the following line:
> 
>   open (WOSSNAME, "(unset EMBOSS_ACDCOMMANDLINE; wossname -alpha -auto)|") || die "Cannot run wossname";

Erm... since you *are* executing this in a separate process, can't you just
unset it even without running it in a subshell?

> This wossname command just prints to stdout a list of available commands from
> the EMBOSS software suite

G'luck,
Peter

-- 
Peter Pentchev	roam@space.bg    roam@ringlet.net    roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
This sentence would be seven words long if it were six words shorter.

Attachment: signature.asc
Description: Digital signature


Reply to: