1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to? SAFEECHO to stderr

Discussion in 'Plugins' started by Stefano Piccardi, Apr 4, 2012.

  1. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    In another thread http://jpsoft.com/forums/threads/echoerr-truncates-long-lines.3861/ I was trying to echoerr a safechar string and found an issue in the Windows API. So, how can I work around that issue starting with from a safechar string in my hands? The goal is to write it to stderr.

    SAFEECHO %@repeat[%@char[%@eval[%@ascii[x]+0xfee0]],%@inc[%_COLUMNS]]
    writes to stdout

    SAFEECHO 1>&2 %@repeat[%@char[%@eval[%@ascii[x]+0xfee0]],%@inc[%_COLUMNS]]
    also writes to stdout

    How to write to stderr? (Safechars Version: 1.5 Build 6)
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    Your second command is writing to stderr.

    You probably think it's going to stdout because it doesn't get colored, but AFAIK ErrorColors only applies to internal commands (including plugins) which specifically open a handle to stdout. It doesn't work with redirection; if you do e.g. PING LOCALHOST 1>&2 the output won't be colored.
     
  3. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    Isn't the second command I posted an internal command?
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    Yes, it is. It just isn't opening its own handle to stderr. It's using the default stdout handle, which just happens to be the same as stderr thanks to your redirection.
     

Share This Page