Skip to content

Instantly share code, notes, and snippets.

@ToxicFrog
Created February 1, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToxicFrog/0619365058f3a6e18bb6d7f341856a32 to your computer and use it in GitHub Desktop.
Save ToxicFrog/0619365058f3a6e18bb6d7f341856a32 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# initial setup to make sure we don't toast the user's real taskdir
export TASKRC=/tmp/$$.taskrc
cat >>"$TASKRC" <<EOF
data.location=/tmp/$$.taskdir
# Bug seems to be related to UDAs specifically; at least, I can't trigger it by editing description.
uda.author.label=Author
uda.author.type=string
# Add the UDA to the report output.
report.list.columns=id,uuid.short,author,description
report.list.labels=ID,UUID,Author,Description
EOF
# Initial task creation. Task one is where the magic happens.
\task add author:"Foo & Bar" "task one"
\task add author:Foo "task two"
\task list
echo '### BEFORE EDIT ###'
cat /tmp/$$.taskdir/pending.data
echo
# Replace that ' & ' in 'Foo & Bar' with a literal \ followed by a newline.
\task rc.editor="sed -E -i 's, & ,\\\\\\n,'" '(description ~ one)' edit
\task list
echo '### AFTER EDIT ###'
cat /tmp/$$.taskdir/pending.data
echo '### END PENDING.DATA ###'
# 2.5.1 here
\task --version
@ToxicFrog
Copy link
Author

TASKRC override: /tmp/75947.taskrc
Created task 1.
TASKRC override: /tmp/75947.taskrc
Created task 2.
TASKRC override: /tmp/75947.taskrc

ID UUID     Author    Description
 1 eac0fdeb Foo & Bar task one
 2 8f687197 Foo       task two   

2 tasks
### BEFORE EDIT ###
[author:"Foo & Bar" description:"task one" entry:"1517493428" modified:"1517493428" status:"pending" uuid:"eac0fdeb-7daf-44c7-9031-77ef40cca2c"]
[author:"Foo" description:"task two" entry:"1517493428" modified:"1517493428" status:"pending" uuid:"8f687197-a201-4a2f-89b9-355899c555f3"

Launching 'sed -E -i 's, & ,\\\n,' "task.eac0fdeb.task"' now...
Editing complete.
Edits were detected.
TASKRC override: /tmp/75947.taskrc
Configuration override rc.editor:sed -E -i 's, & ,\\\n,'
UDA author modified.
TASKRC override: /tmp/75947.taskrc

ID UUID     Author      
 1 8f687197 Foo\[author:

1 task
### AFTER EDIT ###
[author:"Foo\\[author:"Foo" description:"task two" entry:"1517493428" modified:"1517493428" status:"pending" uuid:"8f687197-a201-4a2f-89b9355899c555f3"]
### END PENDING.DATA ###

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment