The characters * and ? are used as wildcards in pathnames. How does one refer to a filename that has ? as one of its actual characters? For example:
[18]> (wild-pathname-p #p"foo")
NIL
[19]> (wild-pathname-p #p"foo?")
T
So referring to the filename "foo?" cannot be done this way. I tried to escape the ? with a backslash, but that didn't work. I tried going unicode by using \u3f or \u003f, but that didn't work.
How do I refer to a file that contains a wildcard as part of its name: How to probe it, open it, etc.?
It depends on the implementation, but for some, a backslash does in fact work. But because namestrings are strings, to get a string with a backslash in it, you have to escape the backslash with another backslash. So, for example, "foo?" is escaped as "foo\\?", not "foo\?".
Last time I checked, in CLISP, there is no way to refer to files with wildcards in the names. My solution to that is to avoid CLISP.
On my Mac running Mac OS X 10.10.3: Clozure CL, SBCL and LispWorks write a pathname with * like this:
#P"/private/tmp/test.\\*"
They might differ in some other details, though.
SBCL supports (make-pathname :directory "" :name file) to escape a string to a proper pathname.
Related
I couldn't find whether Julia provides the OS specific char to separate PATH-like strings, such as PATH=c:\windows\systems32;c:\windows;... and similar environment variables in Linux. OS specific because Windows is using ";" and Linux ":". I neither could find a helper function that does the splitting already and just not exposing the separator char. But couldn't find that either.
It's easy enough to define these myself, I was only surprised not to find them.
thanks lot for your help
No, there isn't a path list separator by default. What you can do is
Sys.iswindows() ? ';' : ':'
For example, in Unix, a backslash (\) is a common escape character. So to escape a full stop (.) in a regular expression, one does this:
\.
But with % encoding URL parameters, we have an escape character, %, and a control code, so an ampersand (&) doesn't become:
%&
Instead, it becomes:
%26
Any reason why? Seems to just make things more complicated, on the face of it, when we could just have one escape character and a mechanism to escape itself where necessary:
%%
Then it'd be:
simpler to remember; we just need to know which characters to escape, not which to escape and what to escape them to
encoding-agnostic, as we wouldn't be sending an ASCII or Unicode representation explicitly, we'd just be sending them in the encoding the rest of the URL is going in
easy to write an encoder: s/[!\*'();:#&=+$,/?#\[\] "%-\.<>\\^_`{|}~]/%&/g (untested!)
better because we could switch to using \ as an escape character, and life would be simpler and it'd be summer all year long
I might be getting carried away now. Someone shoot me down? :)
EDIT: replaced two uses of "delimiter" with "escape character".
Percent encoding happens not only to escape delimiters, but also so that you can transport bytes that are not allowed inside URIs (such as control characters or non-ASCII characters).
I guess it's because the URL Specification and specifically the HTTP part of it, only allow certain characters so to escape those one must replace them with characters that are allowed.
Also some allowed characters have special meanings like & and ? etc
so replacing them with a control code seems the only way to solve it
If you find it hard to recognize them, bookmark this page
http://www.w3schools.com/tags/ref_urlencode.asp
Is it possible to disable Command Substitution in Bash?
I want to pass a string containing several backticks characters as command-line argument to a program, without trailing backslashs or quoting the string.
Thank you.
I assume there is a misconception which grounds your question. Quoting is most likely the solution to your situation. But maybe you haven't found the right way of quoting yet or similar.
If your dangerous string shall be verbatim (without quoting or escaping) in the source code, you can put it in a separate file and read it from there:
dangerous_string=$(cat dangerous_string_file.txt)
If it shall be passed without interpretation to a command, use the double quotes to prevent interpretation:
my_command "$dangerous_string"
If you have to pass it to a command which needs to receive a quoted version of your string because it is known to carelessly pass the string without using sth like the double quotes to prevent interpretation, you can always use printf to get a quoted version:
quoted_dangerous_string=$(printf "%q" "$dangerous_string")
careless_command "$quoted_dangerous_string"
If all these options do not help in your situation, please explain in more detail where your problem lies.
I want to have slash instead of backslash, because my application communicates with a ftp not allowing backslash as directory-seperator.
Is there any shortcut/configuration without writing my own method?
Stealing #Tejs comment as an answer.
Since GetDirectoryName returns a string, you can simply replace the backslashes with the symbol you prefer:
Path.GetDirectoryName(path).Replace("\\", "/")
Is there any special character that cannot be a part of the path in Windows or Unix that I can use it as a separator?
what about the delimiter for PATH environment variable? ; for windows, and : for Linux.
Wikipedia helpfully lists the reserved characters for different filesystems. Neither NTFS nor POSIX will accept the null or slash (/) characters in filenames. The slash character is obviously not a good separator, since it's common in POSIX paths, so maybe you could use null.
Of course null isn't suited to all situations (e.g. it isn't usually visible when printed), in which case you might have to use some sort of escaping scheme.
Java, which aims to work across different platforms, doesn't even try to find a common path separator. Instead each platform has its own character, accessible through an API.
Path separator are platform dependent :
For windows, it’s \ and for unix it’s /.
Technically, Unix does allow any character in a folder/filename, except / of course, which would be interpreted as as part of the path.
Windows does only support printable characters and some special characters excluding \ / : * ? " < > |.
In java you can use:
WindowsNTFileSystem
s.split(File.pathSeparator) for windows it will give ; (semicolon)
s.split(File.separator) for windows it will give \ (backward)
Linux
s.split(File.pathSeparator) for windows it will give : (colon)
s.split(File.separator) for windows it will give / (forward)
I would be careful with custom separators because they might break in the future, e.g. if someone uses unicode and your custom separator is part of another character.