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

Possible bug in zsh



I think I may have encountered a bug in Z shell.  It began when I
tried linking /bin/sh to zsh on FreeBSD-5.1.  When it reboots, I get a
lot of errors from the init scripts because the rootfs does not get
re-mounted read-writable.  I have isolated the piece of init script
code and included a small script below, extracted from the init
scripts and modified for testing, that reproduces the problem.  See
the comments in the script.

The problem goes away if I remove the [ -n "$_precmd" ] statement
which, so far as I can tell, should have no effect on the following if
statement where the problem is.  I tested with zsh-4.0.9 and
zsh-4.1.0.dev5.


<script>

root_start()
{
    # This function normally remounts / in rw mode
    echo "<< Running root_start() >>"
}


_cmd=root_start

if [ -n "$_cmd" ]; then
            # if the precmd failed and force
            # isn't set, exit
            #

    # Remove or comment out these two lines and the problem goes away.
    # ie. zsh does not return 1 in the next statement.
    [ -n "$_precmd" ] &&
        echo "run_rc_command: evaluating ${_precmd}()."

    # $_precmd is null.
    # zsh enters this if statement and returns 1, causing root_start() to
    # never get run, thus leaving /
    # mounted ro.  FreeBSD's sh and bash do not.

    if ! eval $_precmd && [ -z "$rc_force" ]; then
        return 1
    fi

    [ -n "$_cmd" ] &&
        echo "run_rc_command: evaluating ${_cmd}()."
    if ! eval $_cmd && [ -z "$rc_force" ]; then
        return 1
    fi

    return 0
fi

</script>

-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
http://www.InetAddresses.net



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