quitcd.nu: parse ldir by piping through bash

Handles all dir names, even including single-quotes
This commit is contained in:
Joel Kappes 2023-09-28 09:42:23 +02:00
parent 1b9a27a1f7
commit c05bced951
1 changed files with 2 additions and 2 deletions

View File

@ -7,8 +7,8 @@ def-env n [...x] {
^nnn ($x | str join)
let newpath = (
if ($env.NNN_TMPFILE | path exists) {
# FIXME: fails if path contains single-quote
let newpath = (open $env.NNN_TMPFILE | parse "cd '{nnnpath}'").0.nnnpath
let rawpath = (open $env.NNN_TMPFILE | parse --regex 'cd (?P<dir>.+)').0.dir
let newpath = ($rawpath | $"echo ($in)" | /bin/bash -s)
^rm -f $env.NNN_TMPFILE
echo $newpath
} else {