Recall & Review
beginner
What does POSIX compliance mean in scripting?
POSIX compliance means writing scripts that follow a standard set of rules so they work on many different Unix-like systems without changes.
Click to reveal answer
beginner
Why should you avoid using Bash-specific features in portable scripts?
Because Bash-specific features may not exist in other shells, making the script fail on systems without Bash or with different shells.
Click to reveal answer
beginner
Which shell is commonly used as the standard for POSIX-compliant scripts?
The 'sh' shell is the standard shell for POSIX-compliant scripts.
Click to reveal answer
intermediate
Give an example of a command or syntax to avoid for POSIX compliance.
Avoid using '[[ ... ]]' for tests; instead, use '[ ... ]' which is POSIX compliant.
Click to reveal answer
intermediate
How can you check if your script is POSIX compliant?
You can run your script with 'sh' instead of 'bash' and test it on different Unix-like systems or use tools like 'shellcheck' with POSIX mode.
Click to reveal answer
Which shell should you use to write a POSIX-compliant script?
✗ Incorrect
The 'sh' shell is the POSIX standard shell, ensuring portability across systems.
Which test syntax is POSIX compliant?
✗ Incorrect
The single bracket [ ] is POSIX compliant; double brackets [[ ]] are Bash-specific.
What is a risk of using Bash-specific features in scripts?
✗ Incorrect
Bash-specific features may not be supported on other shells, causing script failure.
Which command helps check shell scripts for POSIX compliance?
✗ Incorrect
'shellcheck' is a tool that can analyze shell scripts and warn about non-POSIX usage.
What should you do to ensure your script is portable?
✗ Incorrect
Using POSIX standard commands and syntax ensures the script runs on many systems.
Explain what POSIX compliance means for shell scripting and why it is important.
Think about how scripts run on different systems.
You got /3 concepts.
List some common Bash features to avoid when writing POSIX-compliant scripts and suggest POSIX alternatives.
Focus on test syntax and shell features.
You got /5 concepts.