Re: Different variable assignments

Liste des GroupesRevenir à cu shell 
Sujet : Re: Different variable assignments
De : usenet (at) *nospam* f.winkler-ka.de (Frank Winkler)
Groupes : comp.unix.shell
Date : 12. Oct 2024, 08:42:22
Autres entêtes
Message-ID : <lmuniuF632tU1@mid.individual.net>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird Beta
On 12.10.2024 03:59, Janis Papanagnou wrote:
  >It depends on your shell. If you choose Kornshell you won't have that
  >issue and can write it as you've done with the output as you'd expect.
  >
  >$ uname -a | read var
  >$ echo "$var"
  >Linux [...snip...]
  >
  >The reason is that the last command in a pipeline will (in Kornshell)
  >be executed in the "current" shell context.
Interesting hint! I wasn't aware that there are such differences between the shells. And indeed, some simple tests seem to work in an interactive ksh.
Let's see the whole story. For historical reasons, I'm actually using ksh for almost all scripts instead of bash for interactive use - not knowing about the fact above.
There, I run command A which is producing output and which is calling sub-command B, also producing output. This works fine.
What I want to achieve is to grab some parts of the output and store it in a variable but without changing the output on the screen.
So I tried something like
tty=`tty`
A | tee $tty | ... | read var
"tee `tty`" inside the command fails, so I do it outside. The output of A is still there but B's is gone (because B doesn't know anything about the "tee"?) and the whole thing doesn't seem to be still working. $var is empty, though this is a ksh script and the stuff behind "tee" is also working.
To my understanding, the default B can be changed with an option but when I set it to "B | tee $tty", there's still no output.
AFAIR, "var=`...`" works better but as the primary job is the command itself and the variable is just a spin-off product, I'd prefer to do the assignment at the end. I believe it looks better then ;) ...
Probably it would also be feasible with some temp files but I try to avoid them wherever possible.
Happy week-end!
fw

Date Sujet#  Auteur
11 Oct 24 * Different variable assignments60Frank Winkler
11 Oct 24 +* Re: Different variable assignments33John-Paul Stewart
11 Oct 24 i`* Re: Different variable assignments32Frank Winkler
12 Oct 24 i `* Re: Different variable assignments31Janis Papanagnou
12 Oct 24 i  +* Re: Different variable assignments5Lawrence D'Oliveiro
19 Oct 24 i  i`* Re: Different variable assignments4Kenny McCormack
19 Oct 24 i  i `* Re: Different variable assignments3Janis Papanagnou
19 Oct 24 i  i  `* coprocs in bash & ksh (Was: Different variable assignments)2Kenny McCormack
19 Oct 24 i  i   `- Re: coprocs in bash & ksh (Was: Different variable assignments)1Janis Papanagnou
12 Oct 24 i  +* Re: Different variable assignments24Frank Winkler
12 Oct 24 i  i+- Re: Different variable assignments1Lawrence D'Oliveiro
12 Oct 24 i  i`* Re: Different variable assignments22Janis Papanagnou
12 Oct 24 i  i +* Re: Different variable assignments20Lem Novantotto
12 Oct 24 i  i i`* Re: Different variable assignments19Frank Winkler
12 Oct 24 i  i i +* Re: Different variable assignments3Lem Novantotto
19 Oct 24 i  i i i`* lastpipe (Was: Different variable assignments)2Kenny McCormack
19 Oct 24 i  i i i `- Re: lastpipe (Was: Different variable assignments)1Lem Novantotto
12 Oct 24 i  i i +* Re: Different variable assignments4Lawrence D'Oliveiro
12 Oct 24 i  i i i`* Re: Different variable assignments3Janis Papanagnou
12 Oct 24 i  i i i `* Re: Different variable assignments2Lawrence D'Oliveiro
12 Oct 24 i  i i i  `- Re: Different variable assignments1Janis Papanagnou
13 Oct 24 i  i i +* Re: Different variable assignments3Lem Novantotto
13 Oct 24 i  i i i+- Re: Different variable assignments1Lem Novantotto
13 Oct 24 i  i i i`- Re: Different variable assignments1Lem Novantotto
15 Oct 24 i  i i `* Re: Different variable assignments8Frank Winkler
24 Oct 24 i  i i  `* Re: Different variable assignments7Frank Winkler
24 Oct 24 i  i i   +* Re: Different variable assignments3Kenny McCormack
24 Oct 24 i  i i   i`* Re: Different variable assignments2Frank Winkler
25 Oct 24 i  i i   i `- Re: Different variable assignments1Janis Papanagnou
25 Oct 24 i  i i   `* Re: Different variable assignments3Lem Novantotto
25 Oct 24 i  i i    `* tee with no args is a no-op (Was: Different variable assignments)2Kenny McCormack
25 Oct 24 i  i i     `- Re: tee with no args is a no-op (Was: Different variable assignments)1Lem Novantotto
12 Oct 24 i  i `- Re: Different variable assignments1Frank Winkler
19 Oct 24 i  `- lastpipe (Was: Different variable assignments)1Kenny McCormack
11 Oct 24 `* Re: Different variable assignments26Helmut Waitzmann
11 Oct 24  +* Re: Different variable assignments23Frank Winkler
11 Oct 24  i+* Re: Different variable assignments21Lawrence D'Oliveiro
19 Oct 24  ii`* Re: Different variable assignments20Kenny McCormack
19 Oct 24  ii `* Re: Different variable assignments19Janis Papanagnou
19 Oct 24  ii  +* coproc or whatever in bash and ksh (Was: Different variable assignments)4Kenny McCormack
19 Oct 24  ii  i`* Re: coproc or whatever in bash and ksh (Was: Different variable assignments)3Janis Papanagnou
19 Oct 24  ii  i +- Re: coproc or whatever in bash and ksh (Was: Different variable assignments)1Janis Papanagnou
19 Oct 24  ii  i `- Re: coproc or whatever in bash and ksh (Was: Different variable assignments)1Kenny McCormack
19 Oct 24  ii  `* Re: Different variable assignments14Lawrence D'Oliveiro
20 Oct 24  ii   `* Re: Different variable assignments13Kenny McCormack
20 Oct 24  ii    `* Re: Different variable assignments12Janis Papanagnou
20 Oct 24  ii     `* coprocs - again (Was: Different variable assignments)11Kenny McCormack
25 Oct 24  ii      `* Re: coprocs - again (Was: Different variable assignments)10Janis Papanagnou
25 Oct 24  ii       +* Re: coprocs - again (Was: Different variable assignments)8Lawrence D'Oliveiro
25 Oct 24  ii       i+* Re: coprocs - again (Was: Different variable assignments)6Janis Papanagnou
25 Oct 24  ii       ii`* Subjective "valuations" are all we have (Was: coprocs - again (Was: Different variable assignments))5Kenny McCormack
25 Oct 24  ii       ii `* Re: Subjective "valuations" are all we have (Was: coprocs - again (Was: Different variable assignments))4Janis Papanagnou
25 Oct 24  ii       ii  +- Re: Subjective "valuations" are all we have (Was: coprocs - again (Was: Different variable assignments))1Lem Novantotto
25 Oct 24  ii       ii  `* Re: Subjective "valuations" are all we have (Was: coprocs - again (Was: Different variable assignments))2Kenny McCormack
26 Oct 24  ii       ii   `- Re: Subjective "valuations" are all we have (Was: coprocs - again (Was: Different variable assignments))1Janis Papanagnou
25 Oct 24  ii       i`- Re: coprocs - again (Was: Different variable assignments)1Kenny McCormack
25 Oct 24  ii       `- How to do multiple concurrent coprocs in ksh (Was: coprocs - again (Was: Different variable assignments))1Kenny McCormack
12 Oct 24  i`- Re: Different variable assignments1Christian Weisgerber
15 Nov 24  `* Re: Different variable assignments2Kenny McCormack
16 Nov 24   `- Re: Different variable assignments1Lem Novantotto

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal