Jump to content

Conditions

From Squishu Wiki
Revision as of 12:24, 5 July 2025 by Princesssquishuskush (talk | contribs) (Created page with "== General == * A shell script can test the exit code of any command that can be invoked from the cli ** That's why you should include an exit command at the end of any scripts you write * test and [ ] are synonymous ** don't name programs test or it will get jacked up * Here is the first line of an if statement written each way ** if test -f blah.py ** if [ -f blah.py ] *** The spaces after the first brace and before the second one are required *** Mnemonic: [ ] means...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

General

  • A shell script can test the exit code of any command that can be invoked from the cli
    • That's why you should include an exit command at the end of any scripts you write
  • test and [ ] are synonymous
    • don't name programs test or it will get jacked up
  • Here is the first line of an if statement written each way
    • if test -f blah.py
    • if [ -f blah.py ]
      • The spaces after the first brace and before the second one are required
      • Mnemonic: [ ] means test, and you wouldn't do test-f