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

Re: Redirections and noclobber



Hi Nils, hi all 

(remember to take -devel out if applicable, I'm getting the mail through
the bug address),

Bill Allombert <allomber@math.u-bordeaux.fr> wrote:

> On Thu, Oct 07, 2004 at 10:18:09AM +0200, Frank Küster wrote:
>> 
>> But if I start apt-get upgrade or whatever from my interactive shell
>> with noclobber set, all childs will inherit it. That's how the problem
>> came up.
>
> How ? noclobber is not part of the environment so is not carried out
> by fork() and shells launched by dpkg should not be interative.
>
> bash-2.05a$ set -C
> bash-2.05a$ echo a >bar
> bash-2.05a$ echo b >bar
> bash: bar: cannot overwrite existing file
> bash-2.05a$ ./test.sh
> b
> bash-2.05a$ cat test.sh
> #! /bin/sh
> echo a >foo
> echo b >foo
> cat foo
>
> So I am really interested to know what happens here. 

Nils wrote in his bug report: 

,----
| The postinst script:
| /var/lib/dpkg/info/tetex-base.postinst
| fails if you set bash's "noclobber" (say in your .bashrc via set -o noclobber).
| (yes, I set noclobber in root's .bashrc -- I'm careful)
`----

Therefore I assumed that the "set -o" options get inherited as the
environment does. Which is wrong, according to Bill's test which I can
reproduce here. This is also correct according to POSIX
(http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_12)

Nils, is it possible that your ~/.bashrc is read somehow by
noninteractive shells? I am not very used to the details of bash
invocation; according to the manpage it seems that non-interactive
non-login shells only source $BASH_ENV; I am not sure about
/etc/profile, however.

Regards, Frank

-- 
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer



Reply to: