Skip to content

Commit b6f1a43

Browse files
committed
[shell-] show error for bad $colname in addcol-shell
1 parent a6aee53 commit b6f1a43

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

visidata/shell.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ def inputShell(vd):
248248
cmd = vd.input("sh$ ", type="sh")
249249
if '$' not in cmd:
250250
vd.warning('no $column in command')
251+
else:
252+
import shlex
253+
colnames = [col.name for col in vd.sheet.columns]
254+
badnames = [arg[1:] for arg in shlex.split(cmd) if arg.startswith('$') and arg[1:] not in colnames]
255+
for name in badnames:
256+
vd.fail(f'no such columns: {", ".join([name for name in badnames])}')
251257
return cmd
252258

253259
DirSheet.addCommand('`', 'open-dir-parent', 'vd.push(openSource(source.parent if source.resolve()!=Path(".").resolve() else os.path.dirname(source.resolve())))', 'open parent directory') #1801

0 commit comments

Comments
 (0)