Re: scope of variable in prerm script
Brian Mercer Esq <brian@mercerlegal.com> writes:
> OK, probably a newb question:
>
> In Ondrej's php5-fpm.prerm script he has:
>
> [ -z "$DPKG_MAINTSCRIPT_NAME" ] && DPKG_MAINTSCRIPT_NAME=php5-fpm
> dpkg-maintscript-helper mv_conffile /etc/php5/fpm/main.conf
> /etc/php5/fpm/php-fpm.conf 5.3.5-1 -- "$@"
>
> but for mine I have to do:
>
> export DPKG_MAINTSCRIPT_NAME=php5-fpm
> dpkg-maintscript-helper mv_conffile /etc/php5/fpm/main.conf
> /etc/php5/fpm/php-fpm.conf 5.3.5-1 -- "$@"
>
> Both using #!/bin/sh. How come the variable is available to the child
> script in his prerm script but not mine? Thanks.
That seems backwards:
mrvn@frosties:~% sh
$ export DPKG_MAINTSCRIPT_NAME=php5-fpm; sh -c 'echo $DPKG_MAINTSCRIPT_NAME'
php5-fpm
$ exit
mrvn@frosties:~% sh
$ [ -z "$DPKG_MAINTSCRIPT_NAME" ] && DPKG_MAINTSCRIPT_NAME=php5-fpm; sh -c 'echo $DPKG_MAINTSCRIPT_NAME'
$ exit
Maybe he has an export somewhere else in the script?
mrvn@frosties:~% sh
$ export DPKG_MAINTSCRIPT_NAME; [ -z "$DPKG_MAINTSCRIPT_NAME" ] && DPKG_MAINTSCRIPT_NAME=php5-fpm; sh -c 'echo $DPKG_MAINTSCRIPT_NAME'
php5-fpm
$ exit
MfG
Goswin
Reply to: