File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 351351_tsv_escape_field () {
352352 local value=" $1 "
353353 value=${value// \\ / \\\\ }
354- value=${value// $' \t ' / \\\\ t }
355- value=${value// $' \n ' / \\\\ n }
354+ value=${value// $' \t ' / $' \\ t ' }
355+ value=${value// $' \n ' / $' \\ n ' }
356356 printf " %s" " $value "
357357}
358358
488488unpack_target () {
489489 local escaped_path escaped_branch
490490 local IFS=$' \t '
491- # shellcheck disable=SC2162
492- read _ctx_is_main escaped_path escaped_branch <<< " $1"
491+ read -r _ctx_is_main escaped_path escaped_branch <<< " $1"
493492 _ctx_worktree_path=$( _tsv_unescape_field " $escaped_path " )
494493 _ctx_branch=$( _tsv_unescape_field " $escaped_branch " )
495494}
Original file line number Diff line number Diff line change @@ -68,6 +68,14 @@ teardown() {
6868 [ " $_ctx_branch " = " main" ]
6969}
7070
71+ @test " resolved target escaping round-trips tabs newlines and backslashes" {
72+ local value=" /tmp/path" $' \t ' " with" $' \n ' " chars\\ tail"
73+ local escaped
74+ escaped=$( _tsv_escape_field " $value " )
75+
76+ [ " $( _tsv_unescape_field " $escaped " ) " = " $value " ]
77+ }
78+
7179@test " resolve_worktree sets context globals" {
7280 create_test_worktree " ctx-test"
7381 resolve_worktree " ctx-test" " $TEST_REPO " " $TEST_WORKTREES_DIR " " "
You can’t perform that action at this time.
0 commit comments