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

filesystem: remove /usr/bin/cmd #5014

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lazka
Copy link
Member

@lazka lazka commented Nov 19, 2024

It's not clear why it is there (except for changing COMSPEC somehow, but why?), and it's causing problems such as python/cpython#127001

Ideas what this could break welcome.

@lazka
Copy link
Member Author

lazka commented Nov 19, 2024

@Alexpux do you happen to know why we have /usr/bin/cmd?

@smalltalkman
Copy link

I estimate that deleting cmd will cause many software builds to fail, you can refer to: rmyorston/busybox-w32#297 (comment)

@lazka
Copy link
Member Author

lazka commented Nov 22, 2024

I estimate that deleting cmd will cause many software builds to fail, you can refer to: rmyorston/busybox-w32#297 (comment)

What would removing /usr/bin/cmd change there? Wouldn't cmd.exe not behave the same?

@smalltalkman
Copy link

I estimate that deleting cmd will cause many software builds to fail, you can refer to: rmyorston/busybox-w32#297 (comment)

What would removing /usr/bin/cmd change there? Wouldn't cmd.exe not behave the same?

Removing /usr/bin/cmd will cause cmd //c echo "$1" to enter the cmd console and hang.

The main purpose of func_convert_core_msys_to_w32 is to use cmd in cygwin (msys) to convert unix paths to w32 paths. For example, in my msys2 (under win7, not necessarily the latest):

lenovo@lenovo-PC MSYS /c/Users/lenovo/Desktop
# cmd //c echo /
D:/gym/softwares/msys64/

# cmd //c echo /abc/def
D:/gym/softwares/msys64/abc/def

# cmd //c echo /d/abc/def
D:/abc/def

# cmd //c echo d:\\abd
d:\abd

# cmd //c echo d:\abd
d:abd

# cmd //c echo d:/
d:/

These tasks cannot be accomplished by cmd.exe in Windows.

The above should only apply to cygwin (msys), not to busybox-w32. However, I had to use a script like the following to bypass this limitation in busybox-w32.

#!/bin/sh

if [ x"\$1" == x"//c" ]; then
  shift
  "\$COMSPEC" "/c" "\$@"
else
  "\$COMSPEC" "\$@"
fi

Additionally, the libtool commits related to cmd //c echo ... exist at autotools-mirror/libtool@d9033b1 and autotools-mirror/libtool@ac40b5f . These commits should explain the cause better.

@lazka
Copy link
Member Author

lazka commented Nov 23, 2024

Removing /usr/bin/cmd will cause cmd //c echo "$1" to enter the cmd console and hang.

Works fine here, what am I missing?

$ /C/WINDOWS/system32/cmd.exe //c echo "ok"
ok

@smalltalkman
Copy link

Removing /usr/bin/cmd will cause cmd //c echo "$1" to enter the cmd console and hang.

Works fine here, what am I missing?

$ /C/WINDOWS/system32/cmd.exe //c echo "ok"
ok

About one year ago, I encountered a similar problem. I remember that the test results at that time showed that cmd //c echo ... would hang, and I had to manually kill the cmd process to recover. I just retested it and the results showed that it did work. So please ignore the bad conclusion.

However, deleting /usr/bin/cmd will affect access to cmd when MSYS2_PATH_TYPE=strict is used, which makes PATH very small (I used to use this setting a lot, but rarely do now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants