(Hopefully) properly quote (or not) all variables - bookmarks.sh - Simple bookmark manager
(HTM) hg clone https://bitbucket.org/iamleot/bookmarks.sh
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset b9d9313faba00977897d31c6bdb27174f1f444cd
(DIR) parent a46f3c429b39ef454ab22aeaeee13b881d3b6f6c
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sat, 18 Aug 2018 11:16:46
(Hopefully) properly quote (or not) all variables
Diffstat:
bookmarks.sh | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
---
diff -r a46f3c429b39 -r b9d9313faba0 bookmarks.sh
--- a/bookmarks.sh Mon Jan 15 22:25:30 2018 +0100
+++ b/bookmarks.sh Sat Aug 18 11:16:46 2018 +0200
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2017 Leonardo Taccari
+# Copyright (c) 2017-2018 Leonardo Taccari
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -44,12 +44,12 @@
return
fi
- local id="$1"
- local url="$2"
- local tags="$3"
- local comment="$4"
+ local id=$1
+ local url=$2
+ local tags=$3
+ local comment=$4
- printf "$id\t$url\t$tags\t$comment\n" >> $_bookmarks
+ printf "$id\t$url\t$tags\t$comment\n" >> "${_bookmarks}"
}
#
@@ -62,9 +62,9 @@
return
fi
- local id="$1"
+ local id=$1
- sed -i -e "/^${id} /d" $_bookmarks
+ sed -i -e "/^${id} /d" "${_bookmarks}"
}
#
@@ -73,7 +73,7 @@
list()
{
- cat $_bookmarks
+ cat "${_bookmarks}"
}
#
@@ -87,9 +87,9 @@
return
fi
- local field="$1"
+ local field=$1
- case ${field} in
+ case "${field}" in
@*)
# tag
awk -vtag="${field}" -F '\t' \
@@ -99,15 +99,15 @@
if (tag == t[i])
print
}' \
- $_bookmarks
+ "${_bookmarks}"
;;
*://*)
# url
- awk -vurl="${field}" -F '\t' '$2 == url { print }' $_bookmarks
+ awk -vurl="${field}" -F '\t' '$2 == url { print }' "${_bookmarks}"
;;
*)
# id
- awk -vid="${field}" -F '\t' '$1 == id { print }' $_bookmarks
+ awk -vid="${field}" -F '\t' '$1 == id { print }' "${_bookmarks}"
;;
esac
}
@@ -135,10 +135,10 @@
usage
fi
- local action="$1"
+ local action=$1
shift
- case $action in
+ case "${action}" in
add)
add "$@"
;;