-
-
Notifications
You must be signed in to change notification settings - Fork 289
Use sh alternatives and fix change directory in building shell scripts #769
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
Conversation
The usage of the cd command in the shell scripts under building/ can conflict at some point during the procedure. As far as I'm aware, it's supposed to cd to the parent directory, but it does so strangely. On some occasions, this may cause the directory to switch to /tmp on Linux instead. This commit resolves that by instead using the typical .. syntax, which is a shorthand for the parent directory of the process. Additionally, proper shebangs have been added that instead use "/usr/bin/env sh", which returns the path to a suitable sh alternative: that is, the closest program that can be found using 'sh' in the name. This is one of the most recommended shebangs for a shell script, due to 'env' typically being in the exact same position.
|
this is the same thing ive done yesterday before resorting to that line i ended up with although the only reason why i didnt end up using this, is because if u try to run it with a terminal inside the building folder (or by double clicking the file) it'll work, but it wont work if u try to run it from the main project folder as it'd try to go one folder back from the main project one so what i did was to get the path of the current script (in both batch and shell) and then from there going one folder up although you say in some occasions it doesnt work? never experienced it, what can i do to recreate the issue that you just said? |
I typically use the
Sometimes, it will (quite interestingly) go to the When directly running the command that is used as the input for In summary, considering the environment I have at the moment, perhaps a good way to try and reproduce the issue is maybe share either the current Nix shell configuration I have and test it from there or make a draft pull request, and then use the |
|
I managed to record a proper terminal session using asciinema. I'll see if I can create a draft pull request that includes the (incomplete, due to an outdated Haxe version being in Nixpkgs at the moment, that being 4.3.6) proper Nix shell configuration used here. |
Codename now introduces the usage of Haxe 4.3.7 as the recommended Haxe version, and moves a few files around, including the library installation scripts. The Nix shell configuration has been updated to accomodate for this. Do note that this is an incomplete refactor, and is used for issue reproduction as well. See CodenameCrew#769 for more information.
|
thats so odd |
could vary by distro maybe, especially since they’re using NixOS in this case |
My guess is that it's perhaps an issue with the Nix shell configuration's shell hook, which is typically run on Nix shell startup under special properties, such as additional commands. That might be what's causing the issue on my end, and in the terminal session. It could also theoretically be As I've said in #771, I can perhaps reconfigure the shell hook to run the command line program directly so that the issue is avoided there. Even then, though, the original script only seemed to get the parent directory of the working directory, so that needs to be sorted out. |
|
|
The two prior versions would use the working directory's own parent directory, not the script's. This commit simply makes it so that changing the directory in the script uses its directory's parent instead.
|
I forgot to update the pull request metadata; I'll do so now. |
|
you're right, im getting those annoying errors aswell |
i'll test it soon, thank you very much |
|
it works perfectly fine outisde of the building folder, inside of it and also by double clicking it, tysm!! |

This pull request changes the shell scripts to now use shebangs and to properly change the working directory.
The shebangs point to
/usr/bin/env, which is usually required by UNIX operating systems to be in that exact location, and usesshas that program's first argument. This forces the program to prefer ashvariant in any location; that is,bash,zsh, and the like.The lone
cdline has been simplified to now use"$(dirname "$0")/..", which now uses a relative path to the script to go into the script's parent directory. This resolves multiple issues with the prior version, such as going to the parent directory of the working directory and, when using Nix shells, somehow entering/tmp.