Improve script safety by quoting variables and updating comparisons
This commit updates the `test.sh` script to incorporate best shell scripting practices. Changes include quoting the variables "$SLEEP" and "$EXIT" to handle null or space-containing values better. The arithmetic comparison has been updated to use "bash-style" to improve the script's security. This refactoring aims to enhance the overall efficiency and reliability of the script execution.
This commit is contained in:
		
							parent
							
								
									8581f19127
								
							
						
					
					
						commit
						b0daf0db5f
					
				
							
								
								
									
										10
									
								
								bin/test.sh
								
								
								
								
							
							
						
						
									
										10
									
								
								bin/test.sh
								
								
								
								
							|  | @ -1,18 +1,18 @@ | ||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| SLEEP=${1:-'10'} | SLEEP=${1:-10} | ||||||
| EXIT=${2:-'0'} | EXIT=${2:-0} | ||||||
| 
 | 
 | ||||||
| echo "Sleeping for $SLEEP seconds..."; | echo "Sleeping for $SLEEP seconds..."; | ||||||
| 
 | 
 | ||||||
| sleep $SLEEP; | sleep "$SLEEP"; | ||||||
| 
 | 
 | ||||||
| echo "Waking up!"; | echo "Waking up!"; | ||||||
| 
 | 
 | ||||||
| if [ $EXIT > 0 ]; then | if [ "$EXIT" -gt "0" ]; then | ||||||
|   >&2 echo "Exiting with error code $EXIT"; |   >&2 echo "Exiting with error code $EXIT"; | ||||||
| else | else | ||||||
|   echo "Exiting with error code $EXIT"; |   echo "Exiting with error code $EXIT"; | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| exit $EXIT; | exit "$EXIT"; | ||||||
		Loading…
	
		Reference in New Issue