Open anki-code opened 4 years ago
Hi @laloch! Thank you for the great question!
Can you do
mkdir -p /tmp/$(whoami)/garbage
?
At this time in xonsh 0.9.24 this example is not working and I've tested the @()
operator behavior:
echo 123@('456')
#123456
echo 123@(['456','789'])
# 123456 123789
Python substitution operator expands the prefix and duplicate it. This behavior looks good IMHO.
What about $()
and XEP-2 proposal?
If we install xep-2 fork and try the similar example we can found that XEP-2 logic improves the behavior comparing with current xonsh:
mkdir -p /tmp/dir_test && cd /tmp/dir_test
# xonsh
mkdir -p here/@($(whoami))/garbage
tree here
#here
#└── pc\012
# └── garbage
# 🔴 Unwanted 'pc'$'\n' directory.
# xonsh-xep-2
# pip install -U git+https://github.com/anki-code/xonsh-xep-2
rm -rf here
mkdir -p here/@($(whoami))/garbage
tree here
#here
#└── pc
# └── garbage
# 🟢 Everything as expected.
As result my answer at this time will be: mkdir -p /tmp/$(whoami)/garbage
should do the same as mkdir -p /tmp/@($(whoami))/garbage
along with XEP-2 where $()
is iterable object.
Does it make sense?
Maybe this should be part of the XEP? (make /tmp/$(whoami)/garbage
expand like /tmp/@($(whoami))/garbage
)
Yeah, I think it will be good. I'm waiting here for @laloch feedback as from author of the question. If it works for him I'll be happy to add the suggestion to the XEP-2.
The original question from laloch: