[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: CR/LF




On Sat, 2022-12-10 at 22:10 -0500, Greg Wooledge wrote:
> On Sat, Dec 10, 2022 at 10:07:48PM -0500, Jim Popovitch wrote:
> > On Sat, 2022-12-10 at 20:35 -0600, David Wright wrote:
> > > On Sat 10 Dec 2022 at 21:01:29 (-0500), Jim Popovitch wrote:
> > > > Why does this produce a CR/LF
> > > > 
> > > >  ~$ TEST=$(ssh -o LogLevel=QUIET -t user@server "echo -n ''"); echo ${TEST}
> > > 
> > > Try echo -n ${TEST} at the end.
> > 
> > Thanks, that works if the remote cmd produces no output, but if the
> > remote cmd produces output than the -n strips the intentional CR/LF.
> 
> WOW, THAT WAS FAST!

There's really no need for snark. 
> 
> We have now reached the point where the question has changed, 

No, it's still the same question, perhaps the reader is reading the
question differently now?


> so that the newline-stripping behavior of the $() command substitution is
> relevant.

Thanks, that's been the relevant part all along.


> There is still no CR.  At all.  Ever.  This is not Microsoft Windows.

Why would you assume Windows is involved?  This is about running cmds
from Debian 11 to Debian 11.

> 
> So... what are you actually trying to do?
> 

Run cmds on a remote system, that is captured locally in a variable,
where said cmds may or may not produce output.  If the remote cmd does
not produce any output then there shouldn't be any output, e.g. CR/LF,
returned.

Taking $() out of the equation doesn't change the result. The following
will add a CR/LF: 

  TEST=`ssh -o LogLevel=QUIET -t user@server "echo -n ''"`; echo ${TEST}

Using -n on the 2nd echo would remove a necessary CR/LF on any remote
cmd that did produce output.

-Jim P.



Reply to: