print statement should allow for escaping stuff
This commit is contained in:
parent
d0e3946aff
commit
77ce00970f
3 changed files with 35 additions and 4 deletions
20
cmd/shs.go
20
cmd/shs.go
|
|
@ -31,6 +31,22 @@ const (
|
|||
def_prompt string = "λ "
|
||||
)
|
||||
|
||||
|
||||
// useful for when input contains escape sequences
|
||||
// not checking delims cause thats up to the user who defines their prompts
|
||||
func parseString(in string) string {
|
||||
in = "\"" + in + "\""
|
||||
out, err := strconv.Unquote(in)
|
||||
if err != nil {
|
||||
log.Log(log.ERR,
|
||||
"Couldnt parse (pre?)prompt",
|
||||
"init")
|
||||
return ""
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func setLogLvl(vars ast.VarTable) {
|
||||
var loglvl string
|
||||
|
||||
|
|
@ -80,7 +96,7 @@ func main() {
|
|||
|
||||
prompt_t := ast.GetVar("SHS_STATIC_PROMPT", vars)
|
||||
if prompt_t != nil {
|
||||
prompt = prompt_t.Value()
|
||||
prompt = parseString(prompt_t.Value())
|
||||
} else {
|
||||
prompt = def_prompt
|
||||
}
|
||||
|
|
@ -110,7 +126,7 @@ func main() {
|
|||
if dyn_prompt != nil {
|
||||
p_tok := dyn_prompt.CallFunction(nil, vars, funcs)
|
||||
if p_tok != nil && p_tok.Tag == ast.STRING {
|
||||
prePrompt = p_tok.Value()
|
||||
prePrompt = parseString(p_tok.Value())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue