[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The 'source x' command doesn't keep variables set by x when source o
From: |
#!microsuxx |
Subject: |
Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command |
Date: |
Thu, 14 Nov 2024 00:30:32 +0100 |
another solution
if u parse output u can intercept and parse without piping
exec 2> >( stderr_parser_cmd ) 1> >( stdout parser cmd )
or both in one
or or
another one :
exec >>log 2>&1
set -x
. cmd
i just dunno the exec cmd to bring back the fd 1 and 2 after usage back to
tty , or restore from saved
u can also
eval " &( < a.bash ) "
and anotherone is using $LINENO or some similiar value , on error
On Thu, Nov 14, 2024, 12:09 AM #!microsuxx <fxmbsw7@gmail.com> wrote:
> source is not tty dependand , so try ..
>
> tee -a log < <(
> exec 2>&1
> set -x
> . user.bash
> )
>
> On Wed, Nov 13, 2024, 11:52 PM Yuri <yuri@rawbw.com> wrote:
>
>> On 11/13/24 14:45, #!microsuxx wrote:
>> > depending on actual purpose instead bs demo code , there are serval
>> > approaches to code running code
>>
>>
>> The original code in my project runs 'source x.sh > log' where x.sh is
>> some user-provided script.
>>
>> I wanted to trace the code using 'set -x' in order to report errors
>> locations in scripts to the user.
>> However, the trace also goes to log instead of stdout.
>> When I changed that to 'source x.sh | tee log' - environment variables
>> that the user script x.sh also sets disappeared due to the problem in
>> SUBJECT.
>>
>>
>> This problem makes it very inconvenient to implement features around
>> scripts using 'source'.
>>
>>
>>
>> Yuri
>>
>>
>>
>>
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, (continued)
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Greg Wooledge, 2024/11/13
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Martin D Kealey, 2024/11/13
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Yuri, 2024/11/14
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Chet Ramey, 2024/11/14
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Robert Elz, 2024/11/13
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, #!microsuxx, 2024/11/13
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Yuri, 2024/11/13
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, #!microsuxx, 2024/11/13
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command,
#!microsuxx <=
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Robert Elz, 2024/11/13
- Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Chet Ramey, 2024/11/14
Re: The 'source x' command doesn't keep variables set by x when source output is piped into other command, Chet Ramey, 2024/11/14