Re: Changes to `env' command - Bug in #! processing...

From: Garance A Drosehn (gad_at_FreeBSD.org)
Date: 06/15/05

  • Next message: John Baldwin: "Re: Death to toor"
    Date: Tue, 14 Jun 2005 22:37:28 -0400
    To: freebsd-arch@FreeBSD.org, freebsd-ports@FreeBSD.org
    
    

    Amusingly enough, I had originally posted this as "Changes to the `arg'
    command". That might be a very popular command, if implemented right.

    Anyway, an update on proposed changes to `env':

    At 3:37 PM -0400 6/10/05, Garance A Drosehn wrote:
    >As most people are probably tired of hearing, I recently changed
    >the way the kernel parses #!-lines in shell scripts.
    >
    >I now propose to re-implement that flexibility (and more!) via some
    >changes to the `env' command. The changes add three new (non-standard)
    >options to `env'.
    >
    >I'd like to commit these changes to 6.0, and they should also be fine
    >to MFC to 5.x. They do not depend on the change in kernel-parsing
    >
    >The three new options are:
    > -v -- Turns up a verbosity setting, useful for seeing
    > what `env' is doing. Particularly useful for
    > debugging the following options.
    > -S string -- "split string on spaces". The idea is to take
    > a single string, split it into separate arguments,
    > and then process those arguments. This supports
    > single-quoted strings, double-quoted strings, and
    > a few other features that the previous parsing
    > code was never going to support.
    > -P altpath -- specify a path list to use when searching for the
    > 'utility' (program to execute). `env' does the
    > search itself, without checking or changing the
    > present value of PATH. This was implemented by
    > copying a few routines from the `which' command.
    >
    >Note that due to the parsing-change in 6.0, the -P option is
    >pretty much worthless for scripts in 6.0 without the -S option.
    >
    >These options would then let you have a script start with:
    >
    > #!/usr/bin/env -S /usr/local/bin/php -n -q -dsafe_mode=0
    >
    >which would work exactly the way that:
    >
    > #!/usr/local/bin/php -n -q -dsafe_mode=0
    >
    >does in 5.x-stable. They would also let you have a script which
    >starts with:
    >
    > #!/usr/bin/env -S -P/usr/local/bin:/usr/bin perl
    >
    >and the script will execute /usr/local/bin/perl or /usr/bin/perl,
    >without caring about the present setting for PATH=, and without
    >changing what value the script will see for PATH= when it executes.

    I have worked on it some more, and the -S processing now also
    supports ${SOMEVAR} references. The ${}-format is required, and
    all it supports is environment variables. This gives users even
    more flexibility that they did not have with the previous kernel-
    parsing of options.

    I also wrote up some regression tests for all these changes. Right
    now I have 27 tests, but I intend to have several more by the time
    I'm ready to commit it.

    >The actual update is presently over 300 lines, so I'll just
    >include a pointer to it:
    >http://people.freebsd.org/~gad/env-rel6.diff

    The update is now 486 lines, and has moved to:
    http://people.freebsd.org/~gad/env/env-rel6.diff

    The resulting source file is also available at:
    http://people.freebsd.org/~gad/env/env.c

    Scream now, or, well, scream later...

    -- 
    Garance Alistair Drosehn     =      gad@gilead.netel.rpi.edu
    Senior Systems Programmer               or   gad@FreeBSD.org
    Rensselaer Polytechnic Institute;             Troy, NY;  USA
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
    

  • Next message: John Baldwin: "Re: Death to toor"

    Relevant Pages

    • Re: Leo + Python: the ultimate scripting tool #5
      ... Leo is the ultimate platform on which to run regression tests. ... I use a script to create regression tests based ... No Python test data is created _at all_. ...
      (comp.lang.python)
    • Re: dumping a table in sql insert format?
      ... I would like to set up some regression tests for my ... So I have a script which creates tables, indexes, etc. ... end to initialize some of our "meta" style data, ... plsql developer has a nice test data gnerator feature. ...
      (comp.databases.oracle.misc)
    • Re: dumping a table in sql insert format?
      ... I would like to set up some regression tests for my ... So I have a script which creates tables, indexes, etc. ... end to initialize some of our "meta" style data, ... Oracle's free SQL Developer can do it for you, provided you make some mouse clicks. ...
      (comp.databases.oracle.misc)
    • Re: dumping a table in sql insert format?
      ... I would like to set up some regression tests for my ... So I have a script which creates tables, indexes, etc. ... end to initialize some of our "meta" style data, ... generate the schema export script if I can. ...
      (comp.databases.oracle.misc)