From 8c48eb9057075aba4d76e411aca232125294899b Mon Sep 17 00:00:00 2001 From: Sekulum Forka Date: Mon, 17 May 2021 17:02:51 +0200 Subject: [PATCH] Variables: The 0th frame is the global one, the next few ommits make it so --- src/fsh.nim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fsh.nim b/src/fsh.nim index a2906eb..51fd803 100644 --- a/src/fsh.nim +++ b/src/fsh.nim @@ -311,16 +311,16 @@ proc runBuiltin(builtin: string, args: openArray[string]): (string, int) = of "cd": try: if args.len == 0: - shellVariables[shellVariables.high]["LASTPWD"] = getCurrentDir() + shellVariables[0]["LASTPWD"] = getCurrentDir() setCurrentDir(getHomeDir()) return ("", 0) else: if args[0] == "-": let LASTPWD = getCurrentDir() - setCurrentDir(shellVariables[shellVariables.high]["LASTPWD"]) - shellVariables[shellVariables.high]["LASTPWD"] = LASTPWD + setCurrentDir(shellVariables[0]["LASTPWD"]) + shellVariables[0]["LASTPWD"] = LASTPWD return ("", 0) - shellVariables[shellVariables.high]["LASTPWD"] = getCurrentDir() + shellVariables[0]["LASTPWD"] = getCurrentDir() setCurrentDir(args[0]) return ("", 0) except OsError as e: @@ -375,12 +375,12 @@ when isMainModule: setControlCHook(ctrlc) let stdinstrm = stdin.newFileStream # Set the default prompt - shellVariables[shellVariables.high]["PROMPT"] = "$PWD \\$" - stdout.write(shellVariables[shellVariables.high]["PROMPT"].newStringStream.substitute) + shellVariables[0]["PROMPT"] = "$PWD \\$" + stdout.write(shellVariables[0]["PROMPT"].newStringStream.substitute) while not stdinstrm.atEnd(): try: discard stdinstrm.readCommand.execute - stdout.write(shellVariables[shellVariables.high]["PROMPT"].newStringStream.substitute) + stdout.write(shellVariables[0]["PROMPT"].newStringStream.substitute) except ShellError, ShellCommandError, ShellVariableError: let e = getCurrentException() stderr.write(e.msg, "\n")