Re: dump list of variables



pottmi@xxxxxxxxx wrote:
I am using bash 3.x and would like a way to one of the following:

1) error if a variable is used that is not declared. (set -o
noundeclare).

One way this is done is with the special expansion syntax:

${parameter?word}

If the parameter is not set, then an error message containing word is
displayed. Modify that to :? to check for the parameter being null or
unset.

OK, I already know that that does not exist, but

A quick scan of the bash 3.0 man page comes up with:

-u Treat unset variables as an error when performing parameter
expansion. If expansion is attempted on an unset variable, the shell
prints an error message, and, if not interactive, exits with a non-zero
status.

Also, elsewhere it is documented that "nounset" is the same as "-u".

The error message betrays the Lisp background of whoever implemented
it:

bash: x: unbound variable

Too bad that the shell has no better way to handle this than to bail
out.

hopefully that gives you the idea of what I want.

I want static typechecking, classes with an object-store database,
first class functions and lexical closures, and a native compiler!

:)

2) dump a list of variables.

Try "set" with no arguments.

.



Relevant Pages

  • Re: Ada.Command_Line and wildcards
    ... One criterion is the number of wildcard expansion surprises. ... $ echo *.ads # argument text is a pattern ... the expansion (in the shell!) has: ...
    (comp.lang.ada)
  • Some sh(1) plans for 10.0
    ... Report output errors in builtins (error message and exit status 2). ... Special expansion for assignments in export/readonly/local. ... Users sometimes get confused by this not working and if POSIX plans to ...
    (freebsd-arch)
  • Re: Should integer variables be quoted?
    ... A shell which does this when IFS has the default value has a bug ... After parameter expansion, ... Each variable assignment shall be expanded for tilde expansion, ...
    (comp.unix.shell)
  • Re: Is standalone dollar sign an error?
    ... standard should be interpreted here, ... context of parsing theory and practise. ... The order of word expansion shall be as follows: ... versions of that shell that I am aware of such benchmarks). ...
    (comp.unix.shell)
  • Re: Questions related to - Arg list too long - error
    ... I'm expecting printf or echo to fail, given that initially, there is ... wild card expansion done for them too, same as ls and friends, but no ...  The shell may be able to handle the full wildcard ... The shell does the wildcard expansion, ...
    (comp.unix.shell)