process_comments() {
local comment_mark="${3:-#}"
local comment_text="$1"
local file_name="$2"
echo "In file $file_name, the comment marker is $comment_mark"
echo "$comment_mark $comment_text"
}
#### 调用示例 1:
process_comments "This is a comment" "example.txt" "#"
输出:
In file example.txt, the comment marker is #
# This is a comment
#### 调用示例 2:
process_comments "This is a comment" "example.txt"
输出:
In file example.txt, the comment marker is #
# This is a comment
#### 调用示例 3:
process_comments "This is a comment" "example.txt" "//"
输出:
In file example.txt, the comment marker is //
// This is a comment