I'm trying to simplify switching between KANBANFILE
's using kanban.bash on Windows.
I'm using several aliases such as the following for switching between KANBANFILE
s:
alias k.pos="export KANBANFILE=\"/c/Users/ajleer/OneDrive - Name Of SomeOneDrive/kanbandb/.kanban.pos.csv\""
but the following line breaks it in two different places with an ambigious redirect error which means that the file it's trying to read from isn't there:
update_item_status(){
item="$( cat "${KANBANFILE}" | awk "{ if (NR==$1) print \$0 }" )"
[[ ${#item} == 0 ]] && echo "item $1 not found" && exit 1
if [[ -n "$2" ]]; then # status change
status="$(echo "$item" | awk -F',' '{ print $1 }' | sed 's/"//g' )"
flags="$(echo "$item" | awk -F',' '{ print $4 }' | sed 's/"//g' )"
dates="$(echo "$item" | awk -F',' '{ print $5 }' | sed 's/"//g' )"
newflags="$flags${2:0:1}"
newdates="$dates $(get_current_date)"
[[ "$2" =~ "DONE" ]] && date="$(get_current_date)"
newitem="$item"
newitem="${newitem/$status/$2}"
newitem="${newitem/$flags/$newflags}"
newitem="${newitem/$dates/$newdates}"
KANBANITEMS="$(<$KANBANFILE)" # THE AMBIGUOUS REDIRECT Error Line
echo "${KANBANITEMS//"$item"/"$newitem"}" > "${KANBANFILE}"
echo "$status -> $2"
fi
}
and also here:
update_item(){
item="$( cat "${KANBANFILE}" | awk "{ if (NR==$1) print \$0 }" )"
[[ ${#item} == 0 ]] && echo "item $1 not found" && exit 1
status="$(echo "$item" | awk -F',' '{ print $1 }')"
echo '#
# STATUSES ARE: '${statuses[*]}'
#
'"$item" > "${TMP}".update
${EDITOR} "${TMP}".update
KANBANITEMS="$(<$KANBANFILE)" # THE AMBIGUOUS REDIRECT Error Line
newitem="$(cat "${TMP}".update | tail -n1 )"
echo "${KANBANITEMS//"$item"/"$newitem"}" > "${KANBANFILE}"
echo "updated item $1"
}
So how do I rewrite my KABANFILE export alias so that it doesn't break the code above, but so that I still can have spaces in the path pointing to the .kanban.xxx.csv
file?
The Ambigious Redirect
occurs anytime I use the kanban <task-id>
or kanban <task-id> <status>
command (even though that's really just editing the csv file with the default editor).
P.S. I am using git-bash on Windows aka MINGW64
$KANBANFILE
in those lines, like you have quoted elsewhere?set -x
to show what your script does. You might see what's wrong with the problematic line.KANBANITEMS="$(<"$KANBANFILE")"