File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -155,10 +155,9 @@ remove_note() {
155
155
open_something () {
156
156
if [[ -p /dev/stdin ]]; then
157
157
read -d $" \n" note_names
158
- local buffer=()
159
- while read note_name; do
158
+ while read note_name; do
160
159
buffer+=" ${note_name} ,"
161
- done <<< " $note_names"
160
+ done <<< " $note_names"
162
161
open_note ${buffer[@]}
163
162
elif [ $# -gt 0 ]; then
164
163
open_note " $* "
@@ -169,19 +168,15 @@ open_something() {
169
168
170
169
open_note () {
171
170
local note_path
172
- local ext_check
173
- local buffer=$@
171
+ local ext_check
172
+ local buffer=$@
174
173
local files=()
175
174
176
- OLDIFS=$IFS
177
- IFS=' ,'
178
- for arg in $buffer ; do
179
- ext_check=true
180
- note_path=" $arg "
181
- if echo $note_path | grep -q ' \.[a-z]' ; then
182
- ext_check=false
183
- fi
184
- if [[ " $note_path " != * $file_ext ]] && $ext_check ; then
175
+ OLDIFS=$IFS ; IFS=' ,'
176
+ for file in $buffer ; do
177
+ note_path=$file
178
+ ext_check=$( echo $note_path | grep -e ' \.[a-z]' )
179
+ if [[ -z ${ext_check} ]]; then
185
180
note_path=" $note_path$file_ext "
186
181
fi
187
182
if [ ! -f " $note_path " ]; then
@@ -191,11 +186,10 @@ open_note() {
191
186
printf " Please set \$ EDITOR to edit notes\n"
192
187
exit 1
193
188
fi
194
- files+=(${note_path} )
195
- done
196
- IFS=$OLDIFS
189
+ files+=(" ${note_path} " )
190
+ done ; IFS=$OLDIFS
197
191
198
- $EDITOR ${files[@]} < /dev/tty
192
+ $EDITOR " ${files[@]} " < /dev/tty
199
193
}
200
194
201
195
usage () {
You can’t perform that action at this time.
0 commit comments