rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
670 stars 124 forks source link

Did not enter the directory specified by %HOME% #402

Closed smalltalkman closed 4 months ago

smalltalkman commented 4 months ago

I wanted to specify the HOME directory before starting busybox, but busybox entered the path specified by BB_SYSTEMROOT.

# set BB_SYSTEMROOT=D:/gym/softwares/busybox
# set HOME=%BB_SYSTEMROOT%/home/root
# busybox_pre64 sh -l
D:/gym/softwares/busybox #
D:/gym/softwares/busybox #
D:/gym/softwares/busybox # echo $HOME
D:/gym/softwares/busybox/home/root
D:/gym/softwares/busybox #
D:/gym/softwares/busybox # pwd
D:/gym/softwares/busybox
D:/gym/softwares/busybox #
D:/gym/softwares/busybox # uname --help
BusyBox v1.37.0-PRE-5317-g54dbf0fa5 (2024-04-06 09:03:16 BST)

Usage: uname [-amnrspvio]

Print system information

        -a      Print all
        -m      Machine (hardware) type
        -n      Hostname
        -r      Kernel release
        -s      Kernel name (default)
        -p      Processor type
        -v      Kernel version
        -i      Hardware platform
        -o      OS name
D:/gym/softwares/busybox #

It seems to be related to the code here: https://github.com/rmyorston/busybox-w32/blob/758a72f55360a1f3a5400aeca29bc2ea0647bad1/shell/ash.c#L16242

Also, can I specify the HOME variable in /etc/profile? It would be very convenient if possible.

smalltalkman commented 4 months ago

I wanted to specify the HOME directory before starting busybox, but busybox entered the path specified by BB_SYSTEMROOT.

The directory specified by HOME must exist. Otherwise, it will enter the existing parent directory.

rmyorston commented 4 months ago

can I specify the HOME variable in /etc/profile?

No, that isn't possible. It would be quite easy to add such a feature, but I'm a bit uneasy about the idea. Allowing /etc/profile to change HOME isn't how things work in Unix.

smalltalkman commented 4 months ago

Sorry, I just submitted another issue. https://github.com/rmyorston/busybox-w32/issues/403