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.

Missing set -euo pipefail for strict error handling. Without it, the script will continue executing even if a command fails, and unset variables won't be caught.

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

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 name should be declared as local to avoid polluting the global scope, and $1 should be quoted to prevent word splitting.

Suggestion:

Suggested change
name=$1
local name="$1"

echo Hello $name

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 expansion $name should be quoted to prevent word splitting and globbing. If name contains spaces or special characters, the output will be incorrect.

Suggestion:

Suggested change
echo Hello $name
echo "Hello $name"

}
greet $USER
Comment on lines +4 to +7

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Quote expansions in function body and call site to avoid word-splitting/globbing.

Line 5 and Line 7 should quote variable expansions; otherwise names containing spaces or glob characters can be mangled.

Suggested fix
 greet() {
-  name=$1
-  echo Hello $name
+  name="$1"
+  echo "Hello $name"
 }
-greet $USER
+greet "$USER"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name=$1
echo Hello $name
}
greet $USER
greet() {
name="$1"
echo "Hello $name"
}
greet "$USER"
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 5-5: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 7-7: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hello-ocr.sh` around lines 4 - 7, The variable expansions in the greet
function body and at the call site are not quoted, which can cause
word-splitting and globbing issues when variables contain spaces or special
characters. Quote the $name variable in the echo statement on line 5 and the
$USER variable in the greet function call on line 7 by wrapping them in double
quotes to preserve their values as single arguments.

Source: Linters/SAST tools

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 expansion $USER should be quoted to prevent word splitting and globbing.

Suggestion:

Suggested change
greet $USER
greet "$USER"

Loading