I keep switching between my command prompt and my git bash shell on windows 10. Suppose I copied my current directory to the clipboard in my command prompt(cmd.exe) and want to switch to that directory in my git bash, I wrote a function d2u() in my .bashrc file which converted the windows path to git bash path and executed it, that worked just fine.
anjan@DESKTOP-RPUVCRE MINGW64 /d
$ cat /dev/clipboard
D:\work\playground\reactNative
anjan@DESKTOP-RPUVCRE MINGW64 /d
$ type d2u
d2u is a function
d2u ()
{
cat /dev/clipboard | sed -r "s'\\\\'/'g" | sed -r "s'^D:'/d'g" | sed -r "s'^C:'/c'g"
}
anjan@DESKTOP-RPUVCRE MINGW64 /d
$ pushd d2u
/d/work/playground/reactNative /d /d/work/playground/reactNative /d /d/work/playground/reactNative ~
anjan@DESKTOP-RPUVCRE MINGW64 /d/work/playground/reactNative
However, when I incrementally improved that to pushd to that unixy path in a new function cd2u, it bombs!
anjan@DESKTOP-RPUVCRE MINGW64 /d/work/playground/reactNative
$ type cd2u
cd2u is a function
cd2u ()
{
pushd `cat /dev/clipboard | sed -r "s'\\\\'/'g" | sed -r "s'^D:'/d'g" | sed -r "s'^C:'/c'g" `
}
anjan@DESKTOP-RPUVCRE MINGW64 /d/work/playground/reactNative
$ cd2u
sed: -e expression #1, char 7: unterminated `s' command
/d /d/work/playground/reactNative /d/work/playground/reactNative /d /d/work/playground/reactNative ~
anjan@DESKTOP-RPUVCRE MINGW64 /d
$
what gives ? why do I get this error ?
sed: -e expression #1, char 7: unterminated `s' command
My sed version is relatively new
$ sed --version sed (GNU sed) 4.8