Skip to content

Commit

Permalink
Fix missing hostname on save.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopaganini committed Aug 27, 2024
1 parent ce3c1a2 commit 496110c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions snip
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,18 @@ function check_empty_db() {
die "${PROGRAM}: Database file is empty. Try add something with \"snip add\""
}

# save(desc, cmd) - Save a single entry to the database file.
# save - Save a single entry to the database file.
#
# Args:
# 1) hostname
# 2) description
# 3) command
function save() {
local desc="${1?}"
local cmd="${2?}"
local hostname="${1?}"
local desc="${2?}"
local cmd="${3?}"

echo "$(date '+%Y-%m-%d %H:%M:%S')|${desc}|${cmd}" >>"${DB_FILE}"
echo "${hostname}|$(date '+%Y-%m-%d %H:%M:%S')|${desc}|${cmd}" >>"${DB_FILE}"
}

# add - Add a command to the database.
Expand Down Expand Up @@ -313,7 +319,7 @@ function add() {
done

# Save and delete infile if needed.
save "${desc}" "${cmd}"
save "${HOSTNAME}" "${desc}" "${cmd}"
if ((delete_file)) && [[ -n "${infile}" ]]; then
rm -f "${infile}"
fi
Expand Down

0 comments on commit 496110c

Please sign in to comment.