Bug 10526

Summary: env: invalid number 'VAR' error when using `env -u VAR`
Product: Busybox Reporter: Chris Renshaw <osm0sis>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs, softchemical
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:

Description Chris Renshaw 2017-11-28 00:22:22 UTC
This occurs with `env -u VAR` and `env -u VAR=val`, but interestingly `env VAR=val`, `env -`, `env -i` and `env` all seem to work fine.

I have tested this going back several busybox versions (1.20.2 - 1.27.2), on my own and other public arm+arm64 Android builds as well as the official arm and i686 builds (https://busybox.net/downloads/binaries/1.26.2-defconfig-multiarch/) using my phone and my Ubuntu VM, respectively.

My attempts to debug it have only led to dead ends so far, including trying swapping out the putenv for the commented unsetenv with no luck, but I do know that toybox env -u does work on Android and uses putenv and unsetenv, so it should be possible on that platform and this just seems to be a larger busybox issue overall, independent of platform/architecture.

Let me know if there's anything else I can provide to help debug or fix it.
Comment 1 Jean-Louis Fuchs 2017-12-24 22:04:09 UTC
Here my tests:

$> sudo docker run -ti --rm busybox
/ # busybox
BusyBox v1.27.2 (2017-11-01 22:58:00 UTC) multi-call binary.
...
/ # env -u HOME env
env: invalid number 'HOME'
/ # env -u 1 env
Segmentation fault

Since it said invalid number I tried a number and got a segfault.
Comment 2 Denys Vlasenko 2018-01-10 10:13:40 UTC
Fixed in git:

commit 8d8ee910f0a624fefd2a4aaefeb406003dea7807
Author: Ron Yorston <rmy@pobox.com>
Date:   Mon Dec 25 21:36:05 2017 +0100

    env: -u option fails due to typo