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

Test for right side of a pipe?

Discussion in 'Plugins' started by vefatica, Jul 30, 2010.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,939
    Likes Received:
    30
    How can my plugin command test whether it is on the right side of a pipe?

    Thanks.
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    | How can my plugin command test whether it is on the right side of a
    | pipe?

    _PIPE
    --
    Steve
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,301
    Likes Received:
    39
    I do something like this:

    Code:
    wchar_t shortbuf[shortbuflen] = L"%[_transient]%[_pipe]";
    ExpandVariables( shortbuf, 1 );
    
    if ( wcscmp( shortbuf, L"00" ) == 0 ) {
        //  do stuff ....
    }
    
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,939
    Likes Received:
    30
    I knew that (but didn't think of it, thanks). I was asking how to do it with the API (Win32 or TCC/SDK). I test for the left side of a pipe or redirection by seeing if GetConsoleScreenBufferInfo() works.

    P.S. I use as little of the wcs stuff as possible; it keeps the DLL smaller. KERNEL32 exports several useful lstr... functions.
     
  5. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    604
    Likes Received:
    0
    Does isatty(fileno(stdin)) do what you want? It appears to return properly
    in my tests.

    On Fri, Jul 30, 2010 at 1:52 PM, vefatica <> wrote:




    --
    Jim Cook
    2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Monday.
     

Share This Page