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

Re: /usr/bin/script annoyance



On Sep 16, 12:53pm, Ken Lareau wrote:
} Subject: Re: /usr/bin/script annoyance
}
} In message <19980916114138.A23822@xxxxxxxxxxxx>, Dan Nelson writes:
} >Zefram's solution to this problem is the shortest:
} >> Alternatively, set your SHELL to be the executable of this program:
} >>
} >>        extern char **environ;
} >>        int main(int argc, char **argv)
} >>        {
} >>            if(argc != 0)
} >>                argv[0] = "zsh";
} >>            execve("/usr/local/bin/zsh", argv, environ);
} >>            _exit(1);
} >>        }

It might be better like this:

    main(int argc, char **argv, char **envp)
    {
      if (argc > 0)
	argv[0] = (**argv == '-') ? "-zsh" : "zsh";
      execve("/usr/local/bin/zsh", argv, envp);
      _exit(1);
    }

That handles login shells, which Zefram's doesn't.

} Of course, this brings up one more question... is this something that
} can be fixed eventually in zsh?

The only reasonable runtime fix I can think of would be an environment
variable to specify the emulation mode, which would take precedence over
argv[0].  That would potentially also solve the argv[0]="su" problem for
which I posted a patch some months ago.

An option to compile out argv[0]-based emulation would be possible, but
didn't receive an enthusiastic response the last time it was suggested.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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