Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awk argument issues #664

Open
sethsabar opened this issue Apr 12, 2023 · 7 comments · May be fixed by binpash/shasta#3
Open

awk argument issues #664

sethsabar opened this issue Apr 12, 2023 · 7 comments · May be fixed by binpash/shasta#3

Comments

@sethsabar
Copy link

PaSh has been failing to run some scripts containing awk. I believe the issue is that PaSh is interpreting arguments to awk (ex: $1) as the first argument to the entire script, when it should be interpreting it as the first argument piped into awk (at least this is my interpretation as someone relatively new to shell scripting). I've
pash-awk-issue-files.zip
attached some scripts that run with bash, but have awk issues with PaSh.

@angelhof
Copy link
Member

Hi Seth, could you paste a small example script where that happens and the output of pash with -d 1 when running it? :)

@sethsabar
Copy link
Author

Sure, here's the script:
cd $1 ( export SGDIR=/tmp/sg-$$.0 rm -rf $SGDIR mkdir $SGDIR { find \( -name \*.c -or -name \*.h \) -type f -print0 }</dev/null >$SGDIR/npi-1.0.0 ln $SGDIR/npi-1.0.0 $SGDIR/npi-1.1.0 FNAMELEN=$( { tr \\0 \\n | sed 's|^.*/||' | awk '{s += length($1); n++} END {print s / n}' # shell is interperting $1 as argument from sed # but PaSh is interpreting $1 as original $1 } <$SGDIR/npi-1.0.0 ) echo $FNAMELEN )

and here's the output:
`Daemon: SocketManager: Made sure that socket does not exist
Daemon: SocketManager: Created socket
Daemon: SocketManager: Successfully bound to socket
Daemon: SocketManager: Listenting on socket
Daemon: Received data: Daemon Start

PaSh: Arguments:
PaSh: input ['./3-simp.sh', '../']
PaSh: preprocess_only False
PaSh: output_preprocessed False
PaSh: interactive False
PaSh: command None
PaSh: a False
PaSh: v False
PaSh: x False
PaSh: expand_using_bash_mirror False
PaSh: output_time False
PaSh: debug 1
PaSh: log_file
PaSh: width 4
PaSh: no_optimize False
PaSh: dry_run_compiler False
PaSh: assert_compiler_success False
PaSh: avoid_pash_runtime_completion False
PaSh: profile_driven False
PaSh: output_optimized False
PaSh: graphviz no
PaSh: graphviz_dir /tmp
PaSh: no_eager False
PaSh: no_daemon False
PaSh: parallel_pipelines False
PaSh: r_split_batch_size 1000000
PaSh: r_split False
PaSh: dgsh_tee False
PaSh: speculative False
PaSh: speculation no_spec
PaSh: termination clean_up_graph
PaSh: daemon_communicates_through_unix_pipes False
PaSh: distributed_exec False
PaSh: config_path
PaSh: preprocess_mode pash
PaSh: ----------------------------------------
PaSh Preprocessor: Preprocessing -- Parsing time: 0.443 ms
PaSh Preprocessor: Preprocessing -- PaSh time: 1.053 ms
PaSh Preprocessor: Preprocessing -- Unparsing time: 1.327 ms
PaSh: Preprocessed script stored in: /tmp/pash_lYG2xjY/tmp2zial07f
PaSh: Executing: PASH_TMP_PREFIX=/tmp/pash_lYG2xjY/ pash_shell_name=./3-simp.sh /usr/bin/env bash +a -c source /tmp/pash_lYG2xjY/tmp2zial07f ./3-simp.sh ../
524736: (1) Previous exit status: 0
524736: (1) Previous set state: hBc
Writing vars to: /tmp/pash_lYG2xjY//pash_156062311225329
524736: (1) Bash variables saved in: /tmp/pash_lYG2xjY//pash_156062311225329
524736: (1) Bash set state at start of execution: hBc
From set: hBc
To set: huB
To add: u
To remove:
524736: (1) Set state reverted to PaSh-internal set state: huBc
524736: (2) Before asking the daemon for compilation...
Sending msg to compilation-server: Compile:/tmp/pash_lYG2xjY//pash_32511117413296| Variable File:/tmp/pash_lYG2xjY//pash_156062311225329| Input IR File:/tmp/pash_lYG2xjY/tmpl3yvx3se
Daemon: Received data: Compile:/tmp/pash_lYG2xjY//pash_32511117413296| Variable File:/tmp/pash_lYG2xjY//pash_156062311225329| Input IR File:/tmp/pash_lYG2xjY/tmpl3yvx3se

Daemon: Reading variables from: /tmp/pash_lYG2xjY//pash_156062311225329
Daemon: Variable Reading time: 0.01 ms
Daemon: Variable Tokenizing time: 2.156 ms
Daemon: Variable Loading time: 2.299 ms
Daemon: Selected width: 4
Daemon: Retrieving candidate DF region: /tmp/pash_lYG2xjY/tmpl3yvx3se ... Daemon: Done!
Daemon: Var: 1 value: ../
Daemon: WARNING: Exception caught: InputOutputInformation for cd not provided so considered side-effectful.
Daemon: Daemon Compile time: 0.154 ms
Daemon: Unsafe running: False
Daemon: Waiting for all processes to finish. There are 0 processes remaining.
Daemon: Request handling time: 2.478 ms
Got response from compilation-server: ERROR: 1 failed to compile
524736: (2) Compiler exited with code: 1
524736: (2) Traps set:
Sending msg to compilation-server: Exit:1|Time:
Daemon: Received data: Exit:1|Time:

Daemon: Time part is: Time:

Daemon: Process: 1 exited. Exec time was: None
Daemon: The following process exited: 1
Got response from compilation-server:
From set: huBc
To set: hBc
To add:
To remove: u
524736: (3) Reverted to BaSh set state: hBc
524736: (3) Array: ../
524736: (3) Number of arguments: 1
524736: (3) Reverted to BaSh input arguments: ../
524736: (3) Number of arguments: 1
524736: (4) Restoring previous exit code: 0
524736: (4) Will execute script in /tmp/pash_lYG2xjY/tmppdsademd:
cd $1
524736: (5) BaSh script exited with ec: 0
524736: (5) Writing current BaSh set state to: /tmp/pash_lYG2xjY//pash_JfgblpUgIG
524736: (5) Current BaSh shell: hBc
From set: hBc
To set: huBc
To add: u
To remove:
524736: (5) Reverted to PaSh set state to: huBc
Writing vars to: /tmp/pash_lYG2xjY//pash_JqSsTgiOyy
Execution time: 9.580 ms
524736: (7) Recovering BaSh variables from: /tmp/pash_lYG2xjY//pash_JqSsTgiOyy
/dev/fd/63: line 11: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 11: declare: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 40: declare: PPID: readonly variable
/dev/fd/63: line 51: declare: SHELLOPTS: readonly variable
/dev/fd/63: line 59: declare: UID: readonly variable
524736: (7) Reading current BaSh set state from: /tmp/pash_lYG2xjY//pash_JfgblpUgIG
524736: (7) Current BaSh set state: hBc
524736: (7) Arguments (might) have been updated to be: ../
524736: (7) Current PaSh set state: huBc
From set: huBc
To set: hBc
To add:
To remove: u
524736: (7) Reverted to BaSh set state before exiting: hBc
524736: (7) Reverting last BaSh exit code: 0
524736: (1) Previous exit status: 0
524736: (1) Previous set state: hBc
Writing vars to: /tmp/pash_lYG2xjY//pash_15216515429467
524736: (1) Bash variables saved in: /tmp/pash_lYG2xjY//pash_15216515429467
524736: (1) Bash set state at start of execution: hBc
From set: hBc
To set: huB
To add: u
To remove:
524736: (1) Set state reverted to PaSh-internal set state: huBc
524736: (2) Before asking the daemon for compilation...
Sending msg to compilation-server: Compile:/tmp/pash_lYG2xjY//pash_55572525822152| Variable File:/tmp/pash_lYG2xjY//pash_15216515429467| Input IR File:/tmp/pash_lYG2xjY/tmp__w9tg_j
Daemon: Received data: Compile:/tmp/pash_lYG2xjY//pash_55572525822152| Variable File:/tmp/pash_lYG2xjY//pash_15216515429467| Input IR File:/tmp/pash_lYG2xjY/tmp__w9tg_j

Daemon: Reading variables from: /tmp/pash_lYG2xjY//pash_15216515429467
Daemon: Variable Reading time: 0.006 ms
Daemon: Variable Tokenizing time: 2.65 ms
Daemon: Variable Loading time: 2.792 ms
Daemon: Selected width: 4
Daemon: Retrieving candidate DF region: /tmp/pash_lYG2xjY/tmp__w9tg_j ... Daemon: Done!
Daemon: Var: $ value: None
Daemon: WARNING: Exception caught: InputOutputInformation for export not provided so considered side-effectful.
Daemon: Daemon Compile time: 0.139 ms
Daemon: Unsafe running: False
Daemon: Waiting for all processes to finish. There are 0 processes remaining.
Daemon: Request handling time: 2.953 ms
Got response from compilation-server: ERROR: 2 failed to compile
524736: (2) Compiler exited with code: 1
524736: (2) Traps set:
Sending msg to compilation-server: Exit:2|Time:
Daemon: Received data: Exit:2|Time:

Daemon: Time part is: Time:

Daemon: Process: 2 exited. Exec time was: None
Daemon: The following process exited: 2
Got response from compilation-server:
From set: huBc
To set: hBc
To add:
To remove: u
524736: (3) Reverted to BaSh set state: hBc
524736: (3) Array: ../
524736: (3) Number of arguments: 1
524736: (3) Reverted to BaSh input arguments: ../
524736: (3) Number of arguments: 1
524736: (4) Restoring previous exit code: 0
524736: (4) Will execute script in /tmp/pash_lYG2xjY/tmpqk9esnus:
export SGDIR=/tmp/sg-${$}.0
524736: (5) BaSh script exited with ec: 0
524736: (5) Writing current BaSh set state to: /tmp/pash_lYG2xjY//pash_uvU4WPohFW
524736: (5) Current BaSh shell: hBc
From set: hBc
To set: huBc
To add: u
To remove:
524736: (5) Reverted to PaSh set state to: huBc
Writing vars to: /tmp/pash_lYG2xjY//pash_qsqPsDocYc
Execution time: 8.580 ms
524736: (7) Recovering BaSh variables from: /tmp/pash_lYG2xjY//pash_qsqPsDocYc
/dev/fd/63: line 12: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 12: declare: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 41: declare: PPID: readonly variable
/dev/fd/63: line 53: declare: SHELLOPTS: readonly variable
/dev/fd/63: line 61: declare: UID: readonly variable
524736: (7) Reading current BaSh set state from: /tmp/pash_lYG2xjY//pash_uvU4WPohFW
524736: (7) Current BaSh set state: hBc
524736: (7) Arguments (might) have been updated to be: ../
524736: (7) Current PaSh set state: huBc
From set: huBc
To set: hBc
To add:
To remove: u
524736: (7) Reverted to BaSh set state before exiting: hBc
524736: (7) Reverting last BaSh exit code: 0
524736: (1) Previous exit status: 0
524736: (1) Previous set state: hBc
Writing vars to: /tmp/pash_lYG2xjY//pash_23751072121834
524736: (1) Bash variables saved in: /tmp/pash_lYG2xjY//pash_23751072121834
524736: (1) Bash set state at start of execution: hBc
From set: hBc
To set: huB
To add: u
To remove:
524736: (1) Set state reverted to PaSh-internal set state: huBc
524736: (2) Before asking the daemon for compilation...
Sending msg to compilation-server: Compile:/tmp/pash_lYG2xjY//pash_26386710611541| Variable File:/tmp/pash_lYG2xjY//pash_23751072121834| Input IR File:/tmp/pash_lYG2xjY/tmpbasdpmqx
Daemon: Received data: Compile:/tmp/pash_lYG2xjY//pash_26386710611541| Variable File:/tmp/pash_lYG2xjY//pash_23751072121834| Input IR File:/tmp/pash_lYG2xjY/tmpbasdpmqx

Daemon: Reading variables from: /tmp/pash_lYG2xjY//pash_23751072121834
Daemon: Variable Reading time: 0.008 ms
Daemon: Variable Tokenizing time: 2.541 ms
Daemon: Variable Loading time: 2.702 ms
Daemon: Selected width: 4
Daemon: Retrieving candidate DF region: /tmp/pash_lYG2xjY/tmpbasdpmqx ... Daemon: Done!
Daemon: Var: SGDIR value: /tmp/sg-524736.0
Daemon: WARNING: Exception caught: Command rm has outputs other than streaming.
Daemon: Daemon Compile time: 0.161 ms
Daemon: Unsafe running: False
Daemon: Waiting for all processes to finish. There are 0 processes remaining.
Daemon: Request handling time: 2.885 ms
Got response from compilation-server: ERROR: 3 failed to compile
524736: (2) Compiler exited with code: 1
524736: (2) Traps set:
Sending msg to compilation-server: Exit:3|Time:
Daemon: Received data: Exit:3|Time:

Daemon: Time part is: Time:

Daemon: Process: 3 exited. Exec time was: None
Daemon: The following process exited: 3
Got response from compilation-server:
From set: huBc
To set: hBc
To add:
To remove: u
524736: (3) Reverted to BaSh set state: hBc
524736: (3) Array: ../
524736: (3) Number of arguments: 1
524736: (3) Reverted to BaSh input arguments: ../
524736: (3) Number of arguments: 1
524736: (4) Restoring previous exit code: 0
524736: (4) Will execute script in /tmp/pash_lYG2xjY/tmp6eufb1j3:
rm -rf ${SGDIR}
524736: (5) BaSh script exited with ec: 0
524736: (5) Writing current BaSh set state to: /tmp/pash_lYG2xjY//pash_zkkWCyZNMA
524736: (5) Current BaSh shell: hBc
From set: hBc
To set: huBc
To add: u
To remove:
524736: (5) Reverted to PaSh set state to: huBc
Writing vars to: /tmp/pash_lYG2xjY//pash_lryjCncz27
Execution time: 9.956 ms
524736: (7) Recovering BaSh variables from: /tmp/pash_lYG2xjY//pash_lryjCncz27
/dev/fd/63: line 12: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 12: declare: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 41: declare: PPID: readonly variable
/dev/fd/63: line 53: declare: SHELLOPTS: readonly variable
/dev/fd/63: line 61: declare: UID: readonly variable
524736: (7) Reading current BaSh set state from: /tmp/pash_lYG2xjY//pash_zkkWCyZNMA
524736: (7) Current BaSh set state: hBc
524736: (7) Arguments (might) have been updated to be: ../
524736: (7) Current PaSh set state: huBc
From set: huBc
To set: hBc
To add:
To remove: u
524736: (7) Reverted to BaSh set state before exiting: hBc
524736: (7) Reverting last BaSh exit code: 0
524736: (1) Previous exit status: 0
524736: (1) Previous set state: hBc
Writing vars to: /tmp/pash_lYG2xjY//pash_45002642519855
524736: (1) Bash variables saved in: /tmp/pash_lYG2xjY//pash_45002642519855
524736: (1) Bash set state at start of execution: hBc
From set: hBc
To set: huB
To add: u
To remove:
524736: (1) Set state reverted to PaSh-internal set state: huBc
524736: (2) Before asking the daemon for compilation...
Sending msg to compilation-server: Compile:/tmp/pash_lYG2xjY//pash_34183009622011| Variable File:/tmp/pash_lYG2xjY//pash_45002642519855| Input IR File:/tmp/pash_lYG2xjY/tmphc2xe3sv
Daemon: Received data: Compile:/tmp/pash_lYG2xjY//pash_34183009622011| Variable File:/tmp/pash_lYG2xjY//pash_45002642519855| Input IR File:/tmp/pash_lYG2xjY/tmphc2xe3sv

Daemon: Reading variables from: /tmp/pash_lYG2xjY//pash_45002642519855
Daemon: Variable Reading time: 0.005 ms
Daemon: Variable Tokenizing time: 2.156 ms
Daemon: Variable Loading time: 2.297 ms
Daemon: Selected width: 4
Daemon: Retrieving candidate DF region: /tmp/pash_lYG2xjY/tmphc2xe3sv ... Daemon: Done!
Daemon: Var: SGDIR value: /tmp/sg-524736.0
Daemon: WARNING: Exception caught: InputOutputInformation for mkdir not provided so considered side-effectful.
Daemon: Daemon Compile time: 0.121 ms
Daemon: Unsafe running: False
Daemon: Waiting for all processes to finish. There are 0 processes remaining.
Daemon: Request handling time: 2.44 ms
Got response from compilation-server: ERROR: 4 failed to compile
524736: (2) Compiler exited with code: 1
524736: (2) Traps set:
Sending msg to compilation-server: Exit:4|Time:
Daemon: Received data: Exit:4|Time:

Daemon: Time part is: Time:

Daemon: Process: 4 exited. Exec time was: None
Daemon: The following process exited: 4
Got response from compilation-server:
From set: huBc
To set: hBc
To add:
To remove: u
524736: (3) Reverted to BaSh set state: hBc
524736: (3) Array: ../
524736: (3) Number of arguments: 1
524736: (3) Reverted to BaSh input arguments: ../
524736: (3) Number of arguments: 1
524736: (4) Restoring previous exit code: 0
524736: (4) Will execute script in /tmp/pash_lYG2xjY/tmphhyxu_5w:
mkdir ${SGDIR}
524736: (5) BaSh script exited with ec: 0
524736: (5) Writing current BaSh set state to: /tmp/pash_lYG2xjY//pash_VJ8doO7mPI
524736: (5) Current BaSh shell: hBc
From set: hBc
To set: huBc
To add: u
To remove:
524736: (5) Reverted to PaSh set state to: huBc
Writing vars to: /tmp/pash_lYG2xjY//pash_ANsYcQdyWX
Execution time: 9.444 ms
524736: (7) Recovering BaSh variables from: /tmp/pash_lYG2xjY//pash_ANsYcQdyWX
/dev/fd/63: line 12: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 12: declare: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 41: declare: PPID: readonly variable
/dev/fd/63: line 53: declare: SHELLOPTS: readonly variable
/dev/fd/63: line 61: declare: UID: readonly variable
524736: (7) Reading current BaSh set state from: /tmp/pash_lYG2xjY//pash_VJ8doO7mPI
524736: (7) Current BaSh set state: hBc
524736: (7) Arguments (might) have been updated to be: ../
524736: (7) Current PaSh set state: huBc
From set: huBc
To set: hBc
To add:
To remove: u
524736: (7) Reverted to BaSh set state before exiting: hBc
524736: (7) Reverting last BaSh exit code: 0
524736: (1) Previous exit status: 0
524736: (1) Previous set state: hBc
Writing vars to: /tmp/pash_lYG2xjY//pash_254241593418064
524736: (1) Bash variables saved in: /tmp/pash_lYG2xjY//pash_254241593418064
524736: (1) Bash set state at start of execution: hBc
From set: hBc
To set: huB
To add: u
To remove:
524736: (1) Set state reverted to PaSh-internal set state: huBc
524736: (2) Before asking the daemon for compilation...
Sending msg to compilation-server: Compile:/tmp/pash_lYG2xjY//pash_2874125554959| Variable File:/tmp/pash_lYG2xjY//pash_254241593418064| Input IR File:/tmp/pash_lYG2xjY/tmpru9hc3dd
Daemon: Received data: Compile:/tmp/pash_lYG2xjY//pash_2874125554959| Variable File:/tmp/pash_lYG2xjY//pash_254241593418064| Input IR File:/tmp/pash_lYG2xjY/tmpru9hc3dd

Daemon: Reading variables from: /tmp/pash_lYG2xjY//pash_254241593418064
Daemon: Variable Reading time: 0.004 ms
Daemon: Variable Tokenizing time: 2.18 ms
Daemon: Variable Loading time: 2.315 ms
Daemon: Selected width: 4
Daemon: Retrieving candidate DF region: /tmp/pash_lYG2xjY/tmpru9hc3dd ... Daemon: Done!
Daemon: WARNING: Exception caught: InputOutputInformation for find not provided so considered side-effectful.
Daemon: Daemon Compile time: 0.165 ms
Daemon: Unsafe running: False
Daemon: Waiting for all processes to finish. There are 0 processes remaining.
Daemon: Request handling time: 2.502 ms
Got response from compilation-server: ERROR: 5 failed to compile
524736: (2) Compiler exited with code: 1
524736: (2) Traps set:
Sending msg to compilation-server: Exit:5|Time:
Daemon: Received data: Exit:5|Time:

Daemon: Time part is: Time:

Daemon: Process: 5 exited. Exec time was: None
Daemon: The following process exited: 5
Got response from compilation-server:
From set: huBc
To set: hBc
To add:
To remove: u
524736: (3) Reverted to BaSh set state: hBc
524736: (3) Array: ../
524736: (3) Number of arguments: 1
524736: (3) Reverted to BaSh input arguments: ../
524736: (3) Number of arguments: 1
524736: (4) Restoring previous exit code: 0
524736: (4) Will execute script in /tmp/pash_lYG2xjY/tmpv_hj6a92:
find ( -name *.c -or -name *.h ) -type f -print0
524736: (5) BaSh script exited with ec: 0
524736: (5) Writing current BaSh set state to: /tmp/pash_lYG2xjY//pash_QbFQe6voCQ
524736: (5) Current BaSh shell: hBc
From set: hBc
To set: huBc
To add: u
To remove:
524736: (5) Reverted to PaSh set state to: huBc
Writing vars to: /tmp/pash_lYG2xjY//pash_TLCAgfgsqO
Execution time: 11.394 ms
524736: (7) Recovering BaSh variables from: /tmp/pash_lYG2xjY//pash_TLCAgfgsqO
/dev/fd/63: line 12: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 12: declare: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 41: declare: PPID: readonly variable
/dev/fd/63: line 53: declare: SHELLOPTS: readonly variable
/dev/fd/63: line 61: declare: UID: readonly variable
524736: (7) Reading current BaSh set state from: /tmp/pash_lYG2xjY//pash_QbFQe6voCQ
524736: (7) Current BaSh set state: hBc
524736: (7) Arguments (might) have been updated to be: ../
524736: (7) Current PaSh set state: huBc
From set: huBc
To set: hBc
To add:
To remove: u
524736: (7) Reverted to BaSh set state before exiting: hBc
524736: (7) Reverting last BaSh exit code: 0
524736: (1) Previous exit status: 0
524736: (1) Previous set state: hBc
Writing vars to: /tmp/pash_lYG2xjY//pash_81192990326443
524736: (1) Bash variables saved in: /tmp/pash_lYG2xjY//pash_81192990326443
524736: (1) Bash set state at start of execution: hBc
From set: hBc
To set: huB
To add: u
To remove:
524736: (1) Set state reverted to PaSh-internal set state: huBc
524736: (2) Before asking the daemon for compilation...
Sending msg to compilation-server: Compile:/tmp/pash_lYG2xjY//pash_48391410932480| Variable File:/tmp/pash_lYG2xjY//pash_81192990326443| Input IR File:/tmp/pash_lYG2xjY/tmp0ehkoyj9
Daemon: Received data: Compile:/tmp/pash_lYG2xjY//pash_48391410932480| Variable File:/tmp/pash_lYG2xjY//pash_81192990326443| Input IR File:/tmp/pash_lYG2xjY/tmp0ehkoyj9

Daemon: Reading variables from: /tmp/pash_lYG2xjY//pash_81192990326443
Daemon: Variable Reading time: 0.007 ms
Daemon: Variable Tokenizing time: 2.612 ms
Daemon: Variable Loading time: 2.764 ms
Daemon: Selected width: 4
Daemon: Retrieving candidate DF region: /tmp/pash_lYG2xjY/tmp0ehkoyj9 ... Daemon: Done!
Daemon: Var: SGDIR value: /tmp/sg-524736.0
Daemon: Var: SGDIR value: /tmp/sg-524736.0
Daemon: WARNING: Exception caught: InputOutputInformation for ln not provided so considered side-effectful.
Daemon: Daemon Compile time: 0.136 ms
Daemon: Unsafe running: False
Daemon: Waiting for all processes to finish. There are 0 processes remaining.
Daemon: Request handling time: 2.923 ms
Got response from compilation-server: ERROR: 6 failed to compile
524736: (2) Compiler exited with code: 1
524736: (2) Traps set:
Sending msg to compilation-server: Exit:6|Time:
Daemon: Received data: Exit:6|Time:

Daemon: Time part is: Time:

Daemon: Process: 6 exited. Exec time was: None
Daemon: The following process exited: 6
Got response from compilation-server:
From set: huBc
To set: hBc
To add:
To remove: u
524736: (3) Reverted to BaSh set state: hBc
524736: (3) Array: ../
524736: (3) Number of arguments: 1
524736: (3) Reverted to BaSh input arguments: ../
524736: (3) Number of arguments: 1
524736: (4) Restoring previous exit code: 0
524736: (4) Will execute script in /tmp/pash_lYG2xjY/tmpfe6_58mb:
ln ${SGDIR}/npi-1.0.0 ${SGDIR}/npi-1.1.0
524736: (5) BaSh script exited with ec: 0
524736: (5) Writing current BaSh set state to: /tmp/pash_lYG2xjY//pash_K0THWlIBDB
524736: (5) Current BaSh shell: hBc
From set: hBc
To set: huBc
To add: u
To remove:
524736: (5) Reverted to PaSh set state to: huBc
Writing vars to: /tmp/pash_lYG2xjY//pash_x2TavCIfON
Execution time: 9.553 ms
524736: (7) Recovering BaSh variables from: /tmp/pash_lYG2xjY//pash_x2TavCIfON
/dev/fd/63: line 12: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 12: declare: FUNCNAME: variable may not be assigned value
/dev/fd/63: line 41: declare: PPID: readonly variable
/dev/fd/63: line 53: declare: SHELLOPTS: readonly variable
/dev/fd/63: line 61: declare: UID: readonly variable
524736: (7) Reading current BaSh set state from: /tmp/pash_lYG2xjY//pash_K0THWlIBDB
524736: (7) Current BaSh set state: hBc
524736: (7) Arguments (might) have been updated to be: ../
524736: (7) Current PaSh set state: huBc
From set: huBc
To set: hBc
To add:
To remove: u
524736: (7) Reverted to BaSh set state before exiting: hBc
524736: (7) Reverting last BaSh exit code: 0
awk: 1: unexpected character '.'`

at which point execution freezes.

@angelhof
Copy link
Member

Could try to shrink this test (make it smaller) and make it to work without input files and also print here what bash returns when you run it? I can't reproduce the error. Also what branch of PaSh are you using?

@sethsabar
Copy link
Author

I did a little more toying around and came up with this simple example which works normally but not with PaSh.
rm -f output.txt
(
awk 'length($1) > 5' data.txt > output.txt
)

I made data.txt a few lines of data where some have their first field's value more than 5 characters and some don't. I found that with bash, it works as expected (only the lines for which the first field are more than 5 characters are written to output.txt). But with PaSh all lines of data.txt are written to output.txt. I'm only able to reproduce this error, however, when the awk command is run in a subshell (without the subshell this works fine). My best guess as to what's happening is that in the subshell, PaSh is interpreting $1 to be the first argument to the script (I found that giving this script an argument of any length changed the behavior of PaSh such that nothing was written to output.txt).

I'm using the most up-to-date version of standard PaSh on the main branch.

@angelhof
Copy link
Member

Thank you very much for this! I am really perplexed... it works for me. I paste the output of my PaSh below running on the main branch:

$ git pull
Already up to date.
$ cat data.txt
123456
1234
123456
123456
123456
1234
1234
123456
$ ./pa.sh test.sh
$ cat output.txt
123456
123456
123456
123456
123456

@angelhof
Copy link
Member

I remember that we had the issue that you are describing in the past, but this example works for me... I am not sure why haha

@angelhof
Copy link
Member

A minimal test case for this bug:

$ cat test.sh
echo "abcd" > /tmp/data.txt
echo "abcde" >> /tmp/data.txt
echo "abc" >> /tmp/data.txt
awk 'length($1) > 3' /tmp/data.txt
$ bash test.sh foo
abcd
abcde
$ ./pa.sh test.sh foo
## No output

The culprit is that PaSh messes up single quotes and prints them as double quotes (see output of ./pa.sh -d 1 test.sh foo):

...
## This is what PaSh executes
{ awk "length($1) > 5" data.txt & }
...

@BolunThompson BolunThompson linked a pull request Nov 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants