-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question mark '?' char in a string #64
Comments
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:
```rash
> 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
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:
by not using the |
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.
The text was updated successfully, but these errors were encountered: