Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 65e351b

Browse files
Add POSIX compatibility
1 parent 8cf8129 commit 65e351b

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

‎tusker

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ TICK='\xE2\x9C\x93'
1515
CROSS='\xE2\x9D\x8C'
1616
DELIM='$$$'
1717

18-
functioncheck_args() {
18+
check_args() {
1919
if [ $# -eq 1 ] && ([ "1ドル" = "show" ] || [ "1ドル" = "help" ]); then
2020
return
2121
fi
@@ -25,88 +25,94 @@ function check_args() {
2525
fi
2626

2727
if [ $# -ne 2 ]; then
28-
echo "Not a valid command. Type 'tusker help' for usage."
28+
printf "Not a valid command. Type 'tusker help' for usage.\\n"
2929
exit
3030
fi
3131
}
3232

33-
functioncreate_file() {
34-
mkdir -p $FILE_DIR
33+
create_file() {
34+
mkdir -p "$FILE_DIR"
3535
if [ ! -e "$FILE_NAME" ]; then
3636
touch "$FILE_NAME"
3737
fi
3838
}
3939

40-
function add_task() {
41-
local task_desc="1ドル"
42-
local current_timestamp=$(date +"%d %B %Y %H:%M:%S")
43-
echo -e "$CROSS $DELIM $task_desc $DELIM $current_timestamp" >> $FILE_NAME
40+
add_task() {
41+
task_desc="1ドル"
42+
current_timestamp=$(date +"%d %B %Y %H:%M:%S")
43+
task_string="$CROSS $DELIM $task_desc $DELIM $current_timestamp"
44+
45+
printf "%b\\n" "$task_string" >> "$FILE_NAME"
4446
}
4547

46-
functiondelete_task() {
47-
localtask_id=1ドル
48-
sed -i -e "$task_id""d" $FILE_NAME
48+
delete_task() {
49+
task_id=1ドル
50+
sed -i -e "$task_id""d" "$FILE_NAME"
4951
}
5052

51-
functioncheck_task() {
52-
localtask_id=1ドル
53-
sed -i "$task_id s/^./$TICK/" $FILE_NAME
53+
check_task() {
54+
task_id=1ドル
55+
sed -i "$task_id s/^./$TICK/" "$FILE_NAME"
5456
}
5557

56-
functionuncheck_task() {
57-
localtask_id=1ドル
58-
sed -i "$task_id s/^./$CROSS/" $FILE_NAME
58+
uncheck_task() {
59+
task_id=1ドル
60+
sed -i "$task_id s/^./$CROSS/" "$FILE_NAME"
5961
}
6062

61-
functionshow_tasks() {
62-
localline_count=$(wc -l $FILE_NAME | awk '{print 1ドル}')
63+
show_tasks() {
64+
line_count=$(wc -l $FILE_NAME | awk '{print 1ドル}')
6365

6466
if [ $line_count -eq 0 ]; then
65-
echo "You're all caught up!!"
67+
printf "You're all caught up!!\\n"
6668
return
6769
fi
6870

69-
nl $FILE_NAME | column -t -s $DELIM
71+
nl "$FILE_NAME" | column -t -s $DELIM
7072
}
7173

7274

73-
functionmain() {
74-
check_args $@
75+
main() {
76+
check_args "$@"
7577
create_file
7678

77-
localaction=1ドル
79+
action=1ドル
7880

7981
case $action in
8082
add)
8183
shift
8284
add_task "$*"
83-
echo "Task added"
85+
printf "Task added\\n"
8486
;;
8587

8688
del)
87-
delete_task 2ドル
88-
echo "Task deleted"
89+
delete_task "2ドル"
90+
printf "Task deleted\\n"
8991
;;
9092

9193
check)
92-
check_task 2ドル
93-
echo "Task marked as done"
94+
check_task "2ドル"
95+
printf "Task marked as done\\n"
9496
;;
9597

9698
uncheck)
97-
uncheck_task 2ドル
98-
echo "Task marked as undone"
99+
uncheck_task "2ドル"
100+
printf "Task marked as undone\\n"
99101
;;
100102

101103
show)
102104
show_tasks
103105
;;
104106

105107
help)
106-
echo -n -e "$HELP_MSG"
108+
printf "%s" "$HELP_MSG"
109+
;;
110+
111+
*)
112+
echo "Not a valid command. Type 'tusker help' for usage."
107113
;;
108114

109115
esac
110116
}
111117

112-
main $@
118+
main "$@"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /