Open Bost opened 4 years ago
Thanks for your feedback!
On Sat, Dec 14, 2019 at 07:47:27AM -0800, Bost wrote:
IMO the special meaning of the question mark character '?' in racket should be ignored if it occurs in a string:
> echo "hello ? where are you?" 16:19 /home/bost/ > echo hello '? where are you'? hello ? where are you ? 16:19 /home/bost/ > echo "hello '? where are you'?" 16:19 /home/bost/ > echo '"hello '? where are you'?" hello '? where are you'? 16:20 /home/bost/ > echo '"hello ? where are you?" hello ? where are you? 16:20 /home/bost/ >
As a quick workaround, if you quote a string it is not subject to glob expansion.
> echo '"hello ? where are you?"
hello ? where are you?
You can also use define-unix-pipe
to define a version of |
that
does not automatically glob. You can still use globs by explicitly
using the glob function.
> (define-unix-pipe =unix/no-glob= #:glob-expand? #f)
> =unix/no-glob= echo "hello ? where are you?"
hello ? where are you?
> =unix/no-glob= echo (glob "hello ? where are you?")
Note that this version never explicitly globs anything, with any glob characters.
I could potentially add an option to define-unix-pipe
to give a
(for-syntax) predicate for whether it should do glob transformation.
Do you think you would want that?
And also there should be no blanks inserted between the question marks:
> echo hey '?'?'? hey ? ? ? 16:22 /home/bost/ >
This happens because each '?
is a separate quoted symbol. So the
pipeline spec ends up being (list 'echo 'hey '? '? '?)
. YOu can get
"hey ???"
by using echo hey '???
, putting the quototion marks
together as one symbol. This one I think is behaving properly. I
don't think I would change the behavior of quote in the reader.
That said, it's Racket. You can make a modified reader that treats quote differently if you want.
And at last but not least:
> echo ??? /home/bost/bin /home/bost/dec /home/bost/dev /home/bost/env /home/bost/foo /home/bost/txt 16:24 /home/bost/ >
I'm not sure what you mean by this one. Do you mean that you don't
want automatic globs at all? Or do you just not want ?
to be
treated as a glob character?
In the first case you can define a different subprocess pipe operator
without glob semantics (eg. with define-unix-pipe
). In the other
case... I'm not super keen on writing a new glob function that just
ignores question mark. But you certainly can if you want, and I can
give you some support to hook it into a pipeline operator. (I have
intended to make a "regexp glob" function at some point, but I haven't
ever gotten around to it, and it's not a priority for me any time
soon.)
I'm starting to realize the situation around the ?
and strings delimited by "
/ '
or undelimited at all, is complicated in any shell not just in rash. To give you a bit of the context I'm in:
I'm a bash and/or fish-shell user being unhappy with the scripting languages these shells provide. I'm looking for a shell equipped with a syntactically better and semantically more powerful language, preferably a LISP dialect. And I stumbled upon rash and while giving it a try - I found out the very first example from Rash: The Reckless Racket Shell:
[...] The following program works as you would expect.
#lang rash cd project-directory echo How many Racket files do we have? ls *.rkt | wc -l
despite the claim, is not working as I expect. (i.e I was having false expectations)
So maybe it would be enough just to make this "Hello world" example simpler:
#lang rash
cd project-directory
echo "The number of Racket files we have:"
ls *.rkt | wc -l
by not using the ?
character and by delimiting the string with "
in the echo
command, with a reference to the 2.1 quoting globs of your documentation.
And in the '2.1' paragraph of the docs one explains in detail, with examples, the globing problem (as hinted by the TODO) and adds a reference to the 9 Pattern Matching where the meaning of ?
is explained.
Thank you.
Ah, yes, my documentation is terrible. I've fixed that first example
(which I'm sure I wrote without actually running it (what can go wrong
with an example of using echo
?).
I will eventually improve the documentation generally.
Also note that the meaning of ?
is taken from the glob
function in
file/glob
, not from racket/match
. I've also added a quick link
for that as well.
IMO the special meaning of the question mark character '?' in racket should be ignored if it occurs in a string:
And also there should be no blanks inserted between the question marks:
And at last but not least:
Thanx.