Skip to content

Make all variables show when running `let`

Tom Almeida requested to merge Tommoa/ion:feature/let-shows-all-vars into master

Before this patch, let only shows string and array variables, whilst all mapping types are not shown. In addition, string and array variables are separated from each other by comments.

This patch implements a new function on shell::Variables that returns all the variables in scope and then modifies Shell::list_vars to print all the variables. The syntax returned is equivalent to the method of declaring the variables themselves, however this still results in mapping types being indistinguishable from each other by looking at the output of let (both HashMap and BTreeMap look the same).

Example

Current

# String Variables
HISTORY_SIZE = 1000
HISTFILE_SIZE = 100000
HISTORY_TIMESTAMP = 0
PID = 35715
CMD_DURATION = 91827
UID = 501
? = 0
EUID = 501
HISTFILE_ENABLED = 1

# Array Variables
HISTORY_IGNORE = [ 'no_such_command' , 'whitespace' , 'duplicates' ]
args = [ '-ion' ]
CDPATH = [ ]

New

HISTFILE_SIZE = 100000
HISTORY_IGNORE = [ 'no_such_command', 'whitespace', 'duplicates' ]
args = [ 'target/debug/ion' ]
CDPATH = [ ]
? = 0
PID = 50741
UID = 501
HISTORY_SIZE = 1000
EUID = 501
HISTORY_TIMESTAMP = 0
HISTFILE_ENABLED = 1
CMD_DURATION = 0
icon = [ 'c'='d', 'a'='b', 'b'='c' ]
Edited by Tom Almeida

Merge request reports