Fixed file emptying bug
This commit is contained in:
parent
e1fdeff718
commit
d2c487c412
11
index.n0m
11
index.n0m
@ -71,14 +71,19 @@ $ }
|
||||
# $1: string: restaurant to remove
|
||||
$ remove_restaurant () {
|
||||
$ enforce_arguments "${FUNCNAME[0]}" "$#" 1;
|
||||
$ grep -Fxv "$1" "$restaurant_file" | tee "$restaurant_file" >/dev/null;
|
||||
$ local temp_file;
|
||||
$ temp_file=$(mktemp);
|
||||
$ grep -Fxv "$1" "$restaurant_file" > "$temp_file";
|
||||
$ mv "$temp_file" "$restaurant_file";
|
||||
$ }
|
||||
#
|
||||
# $1: string: restuarant to add
|
||||
$ add_restaurant () {
|
||||
$ enforce_arguments "${FUNCNAME[0]}" "$#" 1;
|
||||
$ (grep -Fxv "$1" "$restaurant_file"; printf '%s\n' "$1") |\
|
||||
$ tee "$restaurant_file" >/dev/null;
|
||||
$ local temp_file;
|
||||
$ temp_file=$(mktemp);
|
||||
$ (grep -Fxv "$1" "$restaurant_file"; printf '%s\n' "$1") > "$temp_file";
|
||||
$ mv "$temp_file" "$restaurant_file";
|
||||
$ }
|
||||
#
|
||||
# $1 (optional): number: 0=don't overwrite, 1=overwrite
|
||||
|
Loading…
Reference in New Issue
Block a user