Use variable quoting

Signed-off-by: Aoi K <koizumi.aoi@kyoko-project.wer.ee>

git-svn-id: file:///srv/svn/repo/kanako/trunk@6 62e5d677-aa6e-8c4a-b8cb-b9416171cb8e
This commit is contained in:
koizumi.aoi 2022-10-11 19:34:08 +00:00
parent 13f6bdfeb4
commit 334729396a

46
kanako
View File

@ -1,19 +1,19 @@
#!/bin/sh -e #!/bin/sh -e
conf_dir=${conf_dir:-$HOME/.config/kanako} conf_dir="${conf_dir:-$HOME/.config/kanako}"
key_dir=${key_dir:-$HOME/.kanako} key_dir="${key_dir:-$HOME/.kanako}"
store_dir=${store_dir:-$HOME/.kanako-store} store_dir="${store_dir:-$HOME/.kanako-store}"
if test -d ${store_dir}; then if test -d "${store_dir}"; then
cd ${store_dir} cd "${store_dir}"
else else
echo "Password store not found!" echo "Password store not found!"
echo "Please run kanako-init" echo "Please run kanako-init"
exit 1 exit 1
fi fi
if test -f ${conf_dir}/kanako.conf; then if test -f "${conf_dir}/kanako.conf"; then
. ${conf_dir}/kanako.conf; . "${conf_dir}/kanako.conf";
else else
echo "Configuration file has not been found!" echo "Configuration file has not been found!"
echo "Copy kanako.conf.example from the repository," echo "Copy kanako.conf.example from the repository,"
@ -22,35 +22,35 @@ else
fi fi
fn_copy() { fn_copy() {
fn_view $1 | ${clip_cmd} fn_view $1 | "${clip_cmd}"
} }
fn_edit() { fn_edit() {
${decrypt_cmd} ${decrypt_args} ${1%%.enc}.enc > ${1%%.enc} "${decrypt_cmd}" "${decrypt_args}" "${1%%.enc}.enc" > "${1%%.enc}"
${EDITOR} ${1%%.enc} "${EDITOR}" "${1%%.enc}"
${encrypt_cmd} ${encrypt_args} ${1%%.enc} > ${1%%.enc}.enc "${encrypt_cmd}" "${encrypt_args}" "${1%%.enc}" > "${1%%.enc}".enc
rm ${1%%.enc} rm "${1%%.enc}"
} }
fn_generate() { fn_generate() {
pwgen -s ${1:-80} pwgen -s "${1:-80}"
} }
fn_list() { fn_list() {
${list_cmd} ${store_dir} "${list_cmd}" "${store_dir}"
} }
fn_new() { fn_new() {
test -d $1 && fn_usage && exit 1 test -d $1 && fn_usage && exit 1
tmpfile=$(mktemp) tmpfile="$(mktemp)"
${EDITOR} ${tmpfile} "${EDITOR}" "${tmpfile}"
mkdir -p $(dirname $1) mkdir -p "$(dirname "$1")"
${encrypt_cmd} ${encrypt_args} ${tmpfile} > ${1%%.enc}.enc "${encrypt_cmd}" "${encrypt_args}" "${tmpfile}" > "${1%%.enc}".enc
rm ${tmpfile} rm ${tmpfile}
} }
fn_trash_directory() { fn_trash_directory() {
rm -rf $@ rm -rf $@
} }
fn_trash_entry() { fn_trash_entry() {
rm -f ${1}${2},enc rm -f "${1}${2}".enc
} }
fn_usage() { fn_usage() {
cat <<EOF cat <<EOF
@ -60,10 +60,10 @@ kanako [copy|edit|gen|list|add|trash|trashd|view] <arguments>
EOF EOF
} }
fn_view() { fn_view() {
if [ -f ${1%%.enc}.enc ]; then if [ -f "${1%%.enc}".enc ]; then
${encrypt_cmd} ${decrypt_args} ${1%%.enc}.enc ${encrypt_cmd} ${decrypt_args} "${1%%.enc}".enc
elif [ -d ${1:-.} ]; then elif [ -d "${1:-.}" ]; then
${list_cmd} ${1:-.} ${list_cmd} "${1:-.}"
else else
fn_usage fn_usage
fi fi