I am trying to pass filenames retrieved from everything voidtools via their es.exe command line (it works similarly to mlocate) to an “image previewer” like gwenview or nsxiv (in wsl environemnt).
This works:
IFS=$'n'; nsxiv $(es keyword1 keyword2)
But this doesn’t work:
IFS=$'n'; nsxiv $(es $(wl-paste))
when keyword1 keyword2
is currently stored in system clipboard.
user@wsl:~$ wl-paste | od -c
0000000 k e y w o r d 1 k e y w o r d
0000020 2 n
0000022
Why? I thought that $() command substitution can be nested. Instead nsxiv returns No such file or directory
es is an alias that converts es.exe output to match wsl environment)
es() {
# Invoke the es.exe with provided arguments and pipe its output
# through sed to replace Windows-style line endings with Unix-style line endings,
# then use xargs to handle newline-delimited input and pass each path as a single argument to wslpath.
# -p argument - search paths
# -sort date-modified - sensible default
# 2>/dev/null - remove "xargs: wslpath: terminated by signal 13"
/mnt/c/Users/user/Downloads/ES-1.1.0.27.x64/es.exe -p -sort date-modified -instance 1.5a "$@" | sed 's/r$//' | xargs -n1 -d'n' wslpath 2>/dev/null
}