Closed wryun closed 2 years ago
I realize this is pretty old, so you might have already figured out what's going on, but it is because fn-%parse
was exported. To get x = es
, there are two remedies I can think of immediately:
local (fn %parse) { x = ... }
or x = `{local (fn %parse) {...}}
to temporarily undefine %parse
.es -p -c 'echo $0'
to prevent functions like %parse
from being imported by the es subprocess. This works for es
, but it's not so great for other commands, e.g., echo $0
rather than es -p -c 'echo $0'
.You might know this trick already, but I tend to use something like printf '<<%s>>\n' $x
to try making sense of confusing shell output like this, especially when I might be dealing with whitespace issues:
emmachisit:~; let (parse = $fn-%parse) fn %parse prompt1 prompt2 {echo -n X; cmd = <={$parse $^prompt1 $^prompt2}; echo -n Z; return $cmd; }
Xemmachisit:~; x = `{./es -c 'echo $0'}
ZXemmachisit:~; printf '<<%s>>\n' $x
Z<<XZ./es>>
<<X>>
Right, not sure how I missed that it was exported. I guess I thought there was something more complex going on. Thanks for explaining - and the printf suggestion is indeed a good one.