what is difference between running two command ./build.sh vs bash ./build.sh
Mohammad Shadab Abedin
Lead Engineer@QuestGlobal| Ex-Engineer@TE connectivity| IOT & IIOT | Smart Home & grid | LoRaWAN & NB-IOT | LWM2M
Running ./build.sh and bash ./build.sh can have different behaviors depending on the permissions and configuration of the shell script build.sh.
1. ./build.sh: This notation executes the script using the shebang line (#!/bin/bash or similar) specified at the beginning of the script. It is dependent on the permissions set for the file. If the script has executable permissions for the current user, it will be executed directly. Otherwise, it will fail.
2. bash ./build.sh: This explicitly calls the Bash interpreter to execute the script, regardless of the shebang line or the file's permissions. It ensures that the script is interpreted by Bash, regardless of the default shell or permissions. This can be useful in cases where you want to ensure a specific shell interpreter is used, or if the script lacks execute permissions.
In summary, ./build.sh executes the script if it has the appropriate permissions and the correct shebang line, while bash ./build.sh explicitly invokes the Bash interpreter to run the script, bypassing permissions checks.