Changeset 6 in code


Ignore:
Timestamp:
Oct 11, 2022, 7:34:08 PM (3 years ago)
Author:
koizumi.aoi
Message:

Use variable quoting

Signed-off-by: Aoi K <koizumi.aoi@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kanako

    r4 r6  
    11#!/bin/sh -e
    22
    3 conf_dir=${conf_dir:-$HOME/.config/kanako}
    4 key_dir=${key_dir:-$HOME/.kanako}
    5 store_dir=${store_dir:-$HOME/.kanako-store}
     3conf_dir="${conf_dir:-$HOME/.config/kanako}"
     4key_dir="${key_dir:-$HOME/.kanako}"
     5store_dir="${store_dir:-$HOME/.kanako-store}"
    66
    7 if test -d ${store_dir}; then
    8         cd ${store_dir}
     7if test -d "${store_dir}"; then
     8        cd "${store_dir}"
    99else
    1010        echo "Password store not found!"
     
    1313fi
    1414
    15 if test -f ${conf_dir}/kanako.conf; then
    16         . ${conf_dir}/kanako.conf;
     15if test -f "${conf_dir}/kanako.conf"; then
     16        . "${conf_dir}/kanako.conf";
    1717else
    1818        echo "Configuration file has not been found!"
     
    2323
    2424fn_copy() {
    25     fn_view $1 | ${clip_cmd}
     25    fn_view $1 | "${clip_cmd}"
    2626}
    2727fn_edit() {
    28     ${decrypt_cmd} ${decrypt_args} ${1%%.enc}.enc > ${1%%.enc}
    29     ${EDITOR} ${1%%.enc}
    30     ${encrypt_cmd} ${encrypt_args} ${1%%.enc} > ${1%%.enc}.enc
    31     rm ${1%%.enc}
     28    "${decrypt_cmd}" "${decrypt_args}" "${1%%.enc}.enc" > "${1%%.enc}"
     29    "${EDITOR}" "${1%%.enc}"
     30    "${encrypt_cmd}" "${encrypt_args}" "${1%%.enc}" > "${1%%.enc}".enc
     31    rm "${1%%.enc}"
    3232}
    3333fn_generate() {
    34     pwgen -s ${1:-80}
     34    pwgen -s "${1:-80}"
    3535}
    3636fn_list() {
    37     ${list_cmd} ${store_dir}
     37    "${list_cmd}" "${store_dir}"
    3838}
    3939fn_new() {
    4040    test -d $1 && fn_usage && exit 1
    4141
    42     tmpfile=$(mktemp)
    43     ${EDITOR} ${tmpfile}
     42    tmpfile="$(mktemp)"
     43    "${EDITOR}" "${tmpfile}"
    4444
    45     mkdir -p $(dirname $1)
    46     ${encrypt_cmd} ${encrypt_args} ${tmpfile} > ${1%%.enc}.enc
     45    mkdir -p "$(dirname "$1")"
     46    "${encrypt_cmd}" "${encrypt_args}" "${tmpfile}" > "${1%%.enc}".enc
    4747    rm ${tmpfile}
    4848}
     
    5151}
    5252fn_trash_entry() {
    53     rm -f ${1}${2},enc
     53    rm -f "${1}${2}".enc
    5454}
    5555fn_usage() {
     
    6161}
    6262fn_view() {
    63     if [ -f ${1%%.enc}.enc ]; then
    64         ${encrypt_cmd} ${decrypt_args} ${1%%.enc}.enc
    65     elif [ -d ${1:-.} ]; then
    66         ${list_cmd} ${1:-.}
     63    if [ -f "${1%%.enc}".enc ]; then
     64        ${encrypt_cmd} ${decrypt_args} "${1%%.enc}".enc
     65    elif [ -d "${1:-.}" ]; then
     66        ${list_cmd} "${1:-.}"
    6767    else
    6868        fn_usage
Note: See TracChangeset for help on using the changeset viewer.