Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hello-ocr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# throwaway file to smoke-test OpenCodeReview (safe to delete)
greet() {
Comment on lines +1 to +3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script is missing set -euo pipefail which is a shell best practice. This enables strict error handling: -e exits on error, -u errors on unset variables, -o pipefail catches failures in piped commands.

Suggestion:

Suggested change
#!/bin/bash
# throwaway file to smoke-test OpenCodeReview (safe to delete)
greet() {
#!/bin/bash
set -euo pipefail
# throwaway file to smoke-test OpenCodeReview (safe to delete)
greet() {

name=$1
echo Hello $name
Comment on lines +4 to +5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable expansions $1 and $name are unquoted. If the value contains spaces or special characters, it can lead to word splitting and globbing issues. Always quote variable expansions.

Suggestion:

Suggested change
name=$1
echo Hello $name
name="$1"
echo "Hello $name"

}
greet $USER

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$USER is also unquoted at the call site. While typically safe, it's best practice to consistently quote all variable expansions to handle edge cases like usernames with special characters.

Suggestion:

Suggested change
greet $USER
greet "$USER"