uftrace icon indicating copy to clipboard operation
uftrace copied to clipboard

argument parsing error for shell script

Open honggyukim opened this issue 6 years ago • 16 comments

Please see below.

$ uftrace record --force python -c 'print("Hello")'
Hello

$ uftrace record --force python3 -c 'print("Hello")'
python3: invalid option -- 'c'
Try 'python3 --help' for more information.

$ python3 -c 'print("Hello")'
Hello

As shown above, python3 doesn't properly accept -c option with uftrace.

honggyukim avatar Oct 16 '19 08:10 honggyukim

The problem is because my system python3 is a shell script, which is located in a different place.

$ which python3
/home/honggyu/src/depot_tools/git/depot_tools/python3

It's actually a shell script.

$ cat /home/honggyu/src/depot_tools/git/depot_tools/python3
#!/usr/bin/env bash

base_dir=$(dirname "$0")

PYTHON3_BIN_RELDIR="$(cat $base_dir/python3_bin_reldir.txt | xargs echo)"
PATH="bootstrap-3.8.0b1.chromium.1_bin/python3/bin":"bootstrap-3.8.0b1.chromium.1_bin/python3/bin/Scripts":"$PATH"
"$base_dir/bootstrap-3.8.0b1.chromium.1_bin/python3/bin/python3" "$@"

It works fine if the proper path is given.

$ uftrace record --force /usr/bin/python3 -c 'print("Hello")'
Hello

It seems that we better pass the arguments properly even to shell script.

honggyukim avatar Oct 16 '19 08:10 honggyukim

There's another case that should work fine.

$ uftrace record -P. -la ninja chrome
ninja: ‘chrome’: No such file or directory

$ ninja chrome
[1/1] Regenerating ninja files
    ...

honggyukim avatar Nov 18 '19 05:11 honggyukim

What's the type of the ninja file? Is it a (shell) script?

namhyung avatar Nov 20 '19 06:11 namhyung

Right. ninja is also a shell script file. It may be the same issue.

honggyukim avatar Nov 20 '19 06:11 honggyukim

Could I take this issue?

keltion avatar Jul 13 '22 17:07 keltion

Thanks @keltion. Sure, please go ahead and let me know if you have some issues.

honggyukim avatar Jul 13 '22 17:07 honggyukim