FS#71381 - [code] Do not depend on bash

Attached to Project: Community Packages
Opened by Mynacol (mynacol) - Monday, 28 June 2021, 11:37 GMT
Last edited by Massimiliano Torromeo (mtorromeo) - Friday, 28 April 2023, 08:10 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Massimiliano Torromeo (mtorromeo)
Filipe Laíns (FFY00)
Architecture All
Severity Very Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

The /usr/bin/code file currently uses bash.

1. Execution fails for computers without bash.
2. bash is not needed here. Any proper sh should be usable. Might speed up execution.
This task depends upon

Closed by  Massimiliano Torromeo (mtorromeo)
Friday, 28 April 2023, 08:10 GMT
Reason for closing:  Won't implement
Comment by Filipe Laíns (FFY00) - Monday, 28 June 2021, 12:44 GMT
1) is not relevant as bash is a part of the base[1] group, which should be present on *all* Arch Linux installations. If you remove it, you are breaking assumptions several packages make, and your system is not supported by the Arch Linux team.
To properly implement 2), it would require me to change the shebang to #!/usr/bin/env sh, which would probably actually slow down execution as it introduces a new process spawn, and the script itself is 1 line, I doubt even a very efficient sh implementation will make up for that. Changing the shebang to !#/usr/bin/sh would not do anything as it always points to bash in a proper Arch Linux system.

Anyway, I will change the shebang to #!/usr/bin/sh just as a matter of courtesy.

With that said, I want to highlight this is a micro-optimization and IMO not really worth wasting the maintainer's time, especially when so many of us already are short on it. I understand your motivation, and welcome that, but I think there are more efficient ways to contribute. There are many optimizations far more worth of you spending your time following, there are lots of bugs opened in this bug tracker that would benefit from more information gathering and people looking into solutions, etc.
Please understand my intent here is not to tell you off, but rather to make you understand that when you decide to open a bug, people will have to spend time triaging and looking at it, and so, please consider the actual value added by your proposal :P

[1] https://archlinux.org/packages/core/any/base/

Cheers,
Filipe
Comment by Mynacol (mynacol) - Monday, 28 June 2021, 13:04 GMT
Thanks for changing it, and I do believe it makes a difference. I have dash[1] as sh, with a much faster spawn time[2].

[1] https://wiki.archlinux.org/title/Dash
[2] https://unix.stackexchange.com/a/148061
Comment by Eli Schwartz (eschwartz) - Monday, 28 June 2021, 13:58 GMT
I use dash too. In the future, once pacman gains alternatives support, I'd like to see this work out of the box.

That being said, the initial report was incorrect to state point 1, regardless of the validity of point 2.
Comment by Massimiliano Torromeo (mtorromeo) - Friday, 28 April 2023, 08:10 GMT
The original statement that "bash is not needed here" does not apply anymore.

The `code` shell script uses arrays and probably other features not supported by dash and I don't see the value in completely rewriting it to support dash, so I am going to close this issue.

Loading...