Editing variablesIn contrast tozsh , neither bash nor ksh provide an internal command
that allows editing shell variables interactively. To change a variable
setting, a complete assignment name=value has to be
typed in, which is inconvenient and error prone, especially with long values.
The function vared offers a more convenient way. It creates a
temporary file containing the actual variable assignments and launches an
editor. The user can change the assignments at his will, as long as the
shell syntax remains correct. After editing, the file
is executed in the present environment, and then deleted. Using an editor
allows editing any number of variables, including array elements,
complete arrays, and even functions. Of course, any changes are lost
at the end of the current shell. To keep the values, the assignments have to
be put in a permanent (e.g., profile) file.
The function uses the editor given by the variable Besides shell variable settings the function may also be used for editing function definitions. This is convenient if you want to create a function on the fly for testing purposes, and saves you from creating a file yourself, executing it, and deleting it afterwards. You can also modify an existing function without touching the original source, or edit an existing source by providing only the function name. In any case, the altered function is in effect right after closing the editor. See the next page for details. As the two shells differ substantially here, separate versions for Usage: vared -h vared varname -a arrayname arrayname[index] -f -F -p funcname
vared -h prints a short help.
Arrays: Option typeset -a array=([0]='x' [1]='y' [2]='z') typeset -a array=( 'x' 'y' 'z' ) |