Quoting style in C

M

mathieu

Hi

I was struggling with a weird path. So I decided to use a fancy
option in ls to help me out. But I think the output is incorrect.

Steps:
mkdir /tmp/bla
touch "/tmp/bla/filename with | pipe"
ls --quoting-style=c /tmp/bla

returns:

"filename with \| pipe"

I do not think escaping | is correct in C.

Comments ?
-Mathieu
 
R

Richard Bos

mathieu said:
I was struggling with a weird path. So I decided to use a fancy
option in ls to help me out. But I think the output is incorrect.

Steps:
mkdir /tmp/bla
touch "/tmp/bla/filename with | pipe"
ls --quoting-style=c /tmp/bla

returns:

"filename with \| pipe"

I do not think escaping | is correct in C.

You are right. '\|' is not a defined escape character in C; its value is
implementation-defined.
(Of course, one might nit-pick and say that the _style_ of escaping is
that used by C, even if this particular escape _character_ is not in the
C Standard.)

Richard
 
R

Ralf Damaschke

Richard said:
You are right. '\|' is not a defined escape character in C;
its value is implementation-defined.

No, it is not defined (by the grammar rule for escape-sequence)
and requires a diagnostic; there is even a footnote on 6.4.4.4
which explicitly states this.
6.11.4 allows it in extensions though.

Ralf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top