coreutils
coreutils copied to clipboard
Throw error if unset argument starts with '=' for env command
#6165 #6166
Output
Before:
$ cargo run env | grep ZZZ
ZZZ=zzz
$ cargo run env -u=ZZZ | grep ZZZ
(No output because ZZZ was unset)
After:
$ cargo run env | grep ZZZ
ZZZ=zzz
$ cargo run env -u=ZZZ | grep ZZZ
env: cannot unset '=ZZZ': Invalid argument
Try 'target/debug/coreutils env --help' for more information.
Tests:
Before:
$ cargo test test_env_with_gnu_reference_unset_invalid_variables
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 70 filtered out; finished in 0.00s
running 1 test
test test_env::test_env_with_gnu_reference_unset_invalid_variables ... FAILED
failures:
---- test_env::test_env_with_gnu_reference_unset_invalid_variables stdout ----
run: /home/geet/debian-gsoc/coreutils/target/debug/coreutils env -u=2EKt
thread 'test_env::test_env_with_gnu_reference_unset_invalid_variables' panicked at tests/by-util/test_env.rs:578:10:
Command was expected to fail.
stdout = LC_ALL=C
TZ=UTC
stderr =
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
test_env::test_env_with_gnu_reference_unset_invalid_variables
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2875 filtered out; finished in 0.00s
After:
$ cargo test test_env_with_gnu_reference_unset_invalid_variables
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 70 filtered out; finished in 0.00s
running 1 test
test test_env::test_env_with_gnu_reference_unset_invalid_variables ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2875 filtered out; finished in 0.01s
Hi again! I made a mistake and merged your other PR a bit too quickly, which is why the other maintainers had to do a force-push. Sorry ^^'
I'd be happy to help you sort out this mess in case you get stuck with git rebase
. I'm available to chat in the uutils Discord chat.
Hi again! I made a mistake and merged your other PR a bit too quickly, which is why the other maintainers had to do a force-push. Sorry ^^'
I'd be happy to help you sort out this mess in case you get stuck with
git rebase
. I'm available to chat in the uutils Discord chat.
Thanks for your help I will try to fix it and if I fail I will certainly ask you on discord.
Please rebase your work Thanks
Thanks for your patience! Its ready to be reviewed now. I was not able to remove this Add test for ignoring time-style if time not defined commit using rebase as it shows some error.
please fix the lint
please fix the lint
I think all the lint tests have passed, haven't they?
Seems that it needs more work: With this PR:
./target/debug/coreutils env -i -0 -u=kQ4dALb1 A=0d CZj=lYr
env: cannot unset '=kQ4dALb1': Invalid argument
With GNU:
$ /usr/bin/env -i -0 -u=kQ4dALb1 A=0d CZj=lYr
A=0dCZj=lYr%
Seems that it needs more work: With this PR:
./target/debug/coreutils env -i -0 -u=kQ4dALb1 A=0d CZj=lYr env: cannot unset '=kQ4dALb1': Invalid argument
With GNU:
$ /usr/bin/env -i -0 -u=kQ4dALb1 A=0d CZj=lYr A=0dCZj=lYr%
Ok thanks I will look into it.
These are some other results with GNU that don't match:
$ env -0 -u=kQ4dALb1 - A=0d CZj=lYr
A=0dCZj=lYr
$ env -0 -u=kQ4dALb1 - A=0d CZj=lYr
A=0dCZj=lYr
$ env -u=kQ4dALb1 - A=0d CZj=lYr
A=0d
CZj=lYr
$ env -i -u=kQ4dALb1 A=0d CZj=lYr
A=0d
CZj=lYr
I am converting this to a draft pr until I fix these.
Some more deviations from gnu are
$ env D=ddsa - A=0d CZj=lYr
env: ‘-’: No such file or directory
$ cargo run env D=ddsa - A=0d CZj=lYr
D=ddsa
A=0d
CZj=lYr
$ env -- -u=kQ4dALb1 A=0d CZj=lYr
(Prints all environment variables)
After some testing I have found that gnu works if there is -i or '-' before or after '-u=adsfas'. Also, when there is '--' before '-u=adfs'. Some help would be appreciated on what should I do.
GNU testsuite comparison:
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/timeout/timeout is no longer failing!
is it ready to be reviewed? Thanks
No, sorry it isn't ready for review. This pr wont work because of so many weird behavior by gnu as mentioned in my previous comments. But I guess the tests might be useful. I might write some more tests if needed?
Sure sounds good :)
I think I have added enough tests.