Re: writing special characters

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Jeremy C. Reed
Date:  
To: plug-discuss
Subject: Re: writing special characters
On Tue, 25 Jan 2005, Ric Fischer wrote:

> > > mv: cannot move `andor' to `and\\/or': No such file or directory
> >
> > You can not use the / (slash) because it means directory.
>
> Actually, that's not quite true. If I
>
> $ cd /home/ric
>
> The '/' (forward slash) character is not part of the names for either
> home or ric. The file system uses it as a delimiter to separate one
> level of the file system from another. It's far more complicated than
> that, but that's a boiled-down explanation. Because the '/' character
> is only a delimiter and not a part of the file system itself, it's a
> legal character in filenames.
>
> For some reason, Bash is auto-escaping things in his command line.
>
> Hmm. This is curious. Bash is holding our hands far more than I
> remember from way, way back when I first played with Unix and learned
> about shell stuff.


It has nothing to do with bash nor any shell. The / is not a valid
character for a basename.

> Does a more modern-day Linux shell guru have an answer?


Is this supposed to be an insult?

I am not "modern-day"? I am not a "Linux guru"? I am not a "shell guru"?

:)

Have a look at coreutils's basename(1) source code. It specifically checks
for '/' as the full pathname delimiter making it impossible for the
POSIX.2 basename to work if the filename actually contained a slash. (See
./config.hin, ./lib/dirname.h, lib/basename.c, and src/basename.c in
coreutils-5.2.1.)

By default, the fnmatch(3) standard C library function uses the slash as
the delimiter.

The NetBSD libc code for file hierarchy traversing
(src/lib/libc/gen/__fts13.c) specifically lists '/' as the pathname
delimiter making it impossible to use a slash in a basename component. I
know it is not Linux -- but it is Unix compatible. (This is fts(3) of
the standard C library.)

Also have a look at GLIBC's string/basename.c for basename(3) aka
gnu_basename -- it also specifically uses a '/' with strrchr(3) to return
the filename. (Also making a slash impossible.)

And see GLIBC's misc/dirname.c for dirname(3) function -- it also
specifically uses the '/' as the pathname separator.

I'm sure I can find examples in the Linux kernel itself, but that may be
for another day.

Jeremy C. Reed

                 technical support & remote administration
                http://www.pugetsoundtechnology.com/



---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss