Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: question mark in filename.



On 2021-01-09 11:02 p.m., Roman Perepelitsa wrote:

My guess is that the name of this file contains something interesting
in place of question marks (ascii 63). Try this:

     ls s,7* | cat -v
     print -r -- s,7* | od -t x1 -An -v

Roman.

Right! I create a similar file:

$ touch s,8,big?improvements?in?code

$ ls s,8*
s,8,big?improvements?in?code

$ print -r -- s,7* | od -t x1 -An -v
 73 2c 37 2c 62 69 67 0a 69 6d 70 72 6f 76 65 6d
 65 6e 74 73 0a 69 6e 0a 63 6f 64 65 0a

$ print -r -- s,8* | od -t x1 -An -v
 73 2c 38 2c 62 69 67 3f 69 6d 70 72 6f 76 65 6d
 65 6e 74 73 3f 69 6e 3f 63 6f 64 65 0a

pasting the two outputs and trimming to the first question mark:

 73 2c 37 2c 62 69 67 0a  << A bleeding linefeed!
73 2c 38 2c 62 69 67 3f  << A real question mark.

... which is exactly what tried to show when printing my '$output', it broke on the 'question marks' that are really newlines anyway.  So a better question is why ls does this:

$ ls -1 s,[7,8]*
s,7,big?improvements?in?code
s,8,big?improvements?in?code

Anyway the former was auto generated by a utility I have and it was clearly in a buggy state when it made that file.  And now we know that 'ls' replaces linefeeds with question marks, thanks Richard Stallman.  Maybe any non-visible character?  But then again 'eval' uses question marks the first time and spaces the second so it's not just an issue with 'ls'.

Nice call Roman.







Messages sorted by: Reverse Date, Date, Thread, Author