commit 80a2cb9
hovercats
·
2024-09-06 01:52:55 +0000 UTC
parent 080f624
bmks: switch test usage for variables in favor of internal tool. | fix if statement not being properly isolated, making some lines run wether or not it should.
1 files changed,
+7,
-7
M
rc/bmks
M
rc/bmks
+7,
-7
1@@ -11,19 +11,19 @@ fn usage {
2 }
3
4 fn add {
5- test -z $2 || printf 'No url\n'
6- description=`{printf '' | dmenu -c -p 'Description: '}
7- if (test -z $description)
8- printf %s $url >> $bookmarks
9- if not
10+ if (! ~ $2 0) description=`{printf '' | dmenu -c -p 'Description: '}
11+ if not printf 'No url\n' && exit 1
12+ if (~ $#description 0) printf %s $url >> $bookmarks
13+ if not {
14 printf '%s ' $"description - $url >> $bookmarks
15 sed 's/[ ]*$//' $bookmarks > _
16 mv -f _ $bookmarks
17+ }
18 }
19
20 fn del {
21 selection=`{cat $bookmarks | dmenu -l 10 -c -p 'Delete: '}
22- test ! -z $selection || exit 1
23+ if (~ $#selection 0) printf 'No selction made\n' && exit 1
24 grep -v $"selection $bookmarks > _
25 mv -f _ $bookmarks
26 }
27@@ -34,7 +34,7 @@ fn list {
28
29 fn go_to {
30 selection=`{cat $bookmarks | dmenu -c -i -l 10 | awk '{print $NF}'}
31- test ! -z $selection || exit 1
32+ if (~ $#selection 0) printf 'No selection make\n' && exit 1
33 exec $BROWSER $selection
34 }
35