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

env: validate -u argument #266

Merged
merged 1 commit into from
Sep 28, 2023
Merged

env: validate -u argument #266

merged 1 commit into from
Sep 28, 2023

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Sep 28, 2023

  • Standard env command does not support -u NAME for unsetting a variable [1]
  • OpenBSD env doesn't implement -u, but NetBSD and GNU do
  • GNU env prevents argument to -u from having a '=' character
  • NetBSD does the same, and its manual explicitly mentions this restriction
  1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html

* Standard env command does not support -u NAME for unsetting a variable [1]
* OpenBSD env doesn't implement -u, but NetBSD and GNU do
* GNU env prevents argument to -u from having a '=' character
* NetBSD does the same, and its manual explicitly mentions this restriction

1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html
@briandfoy briandfoy self-assigned this Sep 28, 2023
@briandfoy briandfoy added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: env The env program labels Sep 28, 2023
@@ -28,7 +28,12 @@ while ( @ARGV && $ARGV[0] =~ /^-/ ) {
if ( $arg eq '-i' ) {
%ENV = ();
} elsif ( $arg =~ /^-u(.*)/ ) {
delete $ENV{ length($1) ? $1 : shift };
my $val = length $1 ? $1 : shift;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit ugly, but until we switch to Get::Opts, this is fine. I've done it like this before but I've never been happy with it.

@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Sep 28, 2023
@briandfoy briandfoy merged commit f6ca0cc into briandfoy:master Sep 28, 2023
1 check passed
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: env The env program Status: released there is a new release with this fix Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants