Skip to content

Conversation

@rfay
Copy link

@rfay rfay commented Sep 23, 2024

The postCreateCommand.sh is already executable in git as checked in here, and so chmod isn't needed. But even if it were, just running the script with bash is probably nicer.

The postCreateCommand.sh is already executable in git as checked in here, and so `chmod` isn't needed. But even if it were, just running the script with `bash` is probably nicer.
@mandrasch
Copy link
Owner

mandrasch commented Sep 25, 2024

Thanks for PR and suggestions!

chmod

In my first tests I had this problem that the .sh script was not executable - and I realized that permissions are also stored in git: https://stackoverflow.com/questions/40978921/how-to-add-chmod-permissions-to-file-in-git

As far as I remember I needed to run

chmod +x ./.devcontainer/postCreateCommand.sh

once locally and commit this via git.

Therefore I would leave it here as it is when others follow this tutorial and might have not set their permissions correctly (like I did).

bash

I found this in the documentation

For each command property, if the value is a single string, it will be run in /bin/sh. Use && in a string to execute multiple commands. For example, "yarn install" or "apt-get update && apt-get install -y curl". The array syntax ["yarn", "install"] will invoke the command (in this case yarn) directly without using a shell. Each fires after your source code has been mounted, so you can also run shell scripts from your source tree. For example: bash scripts/install-dev-tools.sh.

What's the advantage running it via bash? Quickly googled it - bash is the standard choice nowadays and has more features?

@rfay
Copy link
Author

rfay commented Sep 25, 2024

bash has been the default for scripts for a long time. Your script has #!/bin/bash so it runs with bash anyway.

I was just saying that if you didn't have confidence that the executable bit was set, you could just do bash <script> instead of chmod.... && ./script.sh.

@mandrasch
Copy link
Owner

bash has been the default for scripts for a long time. Your script has #!/bin/bash so it runs with bash anyway.

I was just saying that if you didn't have confidence that the executable bit was set, you could just do bash <script> instead of chmod.... && ./script.sh.

Ah 💡 I wasn't aware of that!

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