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

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


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

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

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

The error message betrays the Lisp background of whoever implemented

bash: x: unbound variable

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

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: ...
  • 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 ...
  • 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, ...
  • 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). ...
  • Re: Ada.Command_Line and wildcards
    ... wildcard expansion is a shell matter. ... The VMS also won't expand wildcard. ...