Trouble piping

May 20, 2008
11,538
103
Syracuse, NY, USA
I have strings like these (with the leading spaces) in the clipboard.

Code:
            "purple": "#800080",
            "red": "#800000",
            "white": "#C0C0C0",
            "yellow": "#808000"

This works.

Code:
v:\> type clip: | cut -d "\"" -f4
#800080
#800000
#C0C0C0
#808000

But I can pipe no further. Judging by the error message, CUT.EXE is seeing the '|' and everything after it as part of it's command line.

Code:
v:\> type clip: | cut -d "\"" -f4 | grep .
D:\gnu\cut.EXE: |: Invalid argument
D:\gnu\cut.EXE: grep: No such file or directory
D:\gnu\cut.EXE: .: Permission denied

Any idea what's going on? ... and how to work around it?
 
May 20, 2008
11,538
103
Syracuse, NY, USA
Quite fortunately, CUT.EXE is the only app that exhibits this odd behavior. So I must blame CUT.EXE. But I still don't understand how CUT.EXE can see the '|' (and beyond) in it's command line. I reckon TCC would have removed that stuff before starting CUT.EXE.
 

rconn

Administrator
Staff member
May 14, 2008
12,404
152
TCC is scanning the line after the first pipe to determine if you have additional pipes. If so, it prefixes "tcc /c" to the remainder of the line (because something like cut.exe has no idea how to handle a pipe).

In the case of your example, TCC thinks that the second pipe character is inside a double quote so it is ignored.
 
May 20, 2008
11,538
103
Syracuse, NY, USA
I see. Redirection, '>', suffers similarly. And the work-around is (second pipe to get rid of '#').

Code:
v:\> type clip: | cut -d `\^q` -f4 | tr -d #
800080
800000
C0C0C0
808000

Or, type clip: | cut -d `"\^q"` -f4 | tr -d #

It took a bit of trial and error to come up with that one and I don't really understand why it works. I'm guessing that the \^q is still around when TCC starts the first pipe, and that newly-started TCC, not seeing an extra quote, properly starts the second pipe. ... yes/no?

It's a bit confusing, especially because that work-around fails if there's not a second pipe

Thanks!
 
Similar threads
Thread starter Title Forum Replies Date
R Trouble with @REGSET[] Support 6
J Trouble with @full[] function. Support 3
cgunhouse Trouble with Relational Expression Support 4
old coot TC DIR command has trouble on my SSD Support 2
S Trouble accessing results of forum search Support 2
vefatica Trouble closing TCMD Support 0
M Trouble loading alias list Support 2
Jay Sage CascadePoint Fails to Install (And Some Trouble with TCMD) Support 2
S PDIR has trouble processing filenames with embedded percent sign Support 3
Roedy trouble with COPY /U Support 7
Juanma Barranquero Ctrl-C trouble Support 1
J trouble redirecting output to environment variable Support 7
vefatica Piping turns on the cursor Support 0
vefatica Piping to WSL? Support 4
H Behavior change re piping a string to a Java program Support 1
vefatica Piping Cscript.exe to HEAD? Support 9
vefatica Piping the output of a DO loop. Support 4
Peter Murschall TPIPE generate unicode on Piping or redirecting Support 3
vefatica Chaining and piping? Support 2
J Piping ANSI control sequences through 'type' Support 4
rps How to? Piping to View /gb Support 1
vefatica Piping to DO x in @con: Support 10
M Piping and redirection: CON: Support 5
vefatica Redirection vs. piping? Support 4
vefatica Fixed Piping to HEAD adds newlines Support 1
nikbackm Piping to new TCC instance crashes it Support 1
S Ctrl-C handling while piping Support 0

Similar threads