diff --git a/base.nim b/base.nim index 686d368..589827f 100644 --- a/base.nim +++ b/base.nim @@ -174,9 +174,9 @@ proc runDMenu*(data: Info, opts: varargs[string], rofi: bool = false): string = #echo cmd # # Run command and get output - let output = execCmdEx(cmd) - let option:string = strip(output[0]) - return option + var output = execCmdEx(cmd) + output.output.stripLineEnd() + return output.output proc outputData*(data: Info, args: varargs[string]): string {.discardable.} = var output = "" diff --git a/calculate.nim b/calculate.nim index ce692f8..6795132 100644 --- a/calculate.nim +++ b/calculate.nim @@ -7,15 +7,18 @@ proc doCalculation(calc: string) = var info = newInfo("Calculator") let ans_cmd_terse = "echo \"" & calc & "\" | qalc +u8 -terse -color=never | awk '!/^>/ && !/^$/ {gsub(/^[ \\t]+|[ \\t]+$/, \"\", $0); print}'" let ans_cmd_full = "echo \"" & calc & "\" | qalc +u8 -color=never | awk '!/^>/ && !/^$/ {gsub(/^[ \\t]+|[ \\t]+$/, \"\", $0); print}'" - let ans_full = execCmdEx(ans_cmd_full) - let ans_terse = execCmdEx(ans_cmd_terse) - let answers = @[strip(ans_terse.output), - strip(ans_full.output)] + var ans_full = execCmdEx(ans_cmd_full) + ans_full.output.stripLineEnd() + var ans_terse = execCmdEx(ans_cmd_terse) + ans_terse.output.stripLineEnd() + let answers = @[strip(ans_full.output), + strip(ans_terse.output)] let args = concat(answers,@["exit"]) - let cmd = outputData(info, args) + var cmd = outputData(info, args) + cmd.stripLineEnd() if cmd in answers: - discard execCmd("echo \"" & strip(cmd) & "\" | xclip") - elif cmd == "exit": + discard execCmd("echo " & quote(cmd) & " | xclip") + elif cmd == "exit" or cmd == "": return else: doCalculation(cmd)