• 0 posts
  • 4 comments
Joined 2 years ago
Cake day: December 16th, 2024
  • When I do ls --help|less --raw-control-chars it doesn’t show the control characters, and it looks all neat and pretty. Isn’t this the opposite of how it’s supposed to work?!

    You’ve gotten a longer reply to this, but just to make it clear: No, that’s how it’s supposed to work.

    • By default less mangles control characters so they can’t do anything to your display (or bell)
    • With -R, less will pass some control characters through raw and unmangled; enough to give you stuff like pretty colours
    • With -r, less won’t mangle any control characters, which, if you’re doing something stupid like trying to read a binary file, can leave your terminal prompt fucked up and in need of a reset.
  • -q controls output for filenames. From ls.c:

    /* True means output nongraphic chars in file names as '?'.
       (-q, --hide-control-chars)
       qmark_funny_chars and the quoting style (-Q, --quoting-style=WORD) are
       independent.  The algorithm is: first, obey the quoting style to get a
       string representing the file name;  then, if qmark_funny_chars is set,
       replace all nonprintable chars in that string with '?'.  It's necessary
       to replace nonprintable chars even in quoted strings, because we don't
       want to mess up the terminal if control chars get sent to it, and some
       quoting methods pass through control chars as-is.  */
    static bool qmark_funny_chars;