Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #269181
| From | Max Nikulin <manikulin@gmail.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: realpath quoting |
| Date | 2024-05-03 17:20 +0200 |
| Message-ID | <IA2Rz-aPfv-13@gated-at.bofh.it> (permalink) |
| References | <IzNIR-aFv9-1@gated-at.bofh.it> <IzQGJ-aHiZ-1@gated-at.bofh.it> <IzQGJ-aHiZ-3@gated-at.bofh.it> <IzRjr-aHve-1@gated-at.bofh.it> <IzSSd-aIFM-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 03/05/2024 11:31, jeremy ardley wrote:
> My use case is very simple. Give an argument to a program that expects a
> single filename/path.
Role of realpath in your workflow is not clear for me yet.
If you need to copy its result to clipboard then you may use xsel,
xclip, etc.
realpath --zero "$file" |
{ IFS= read -r -d '' path ; printf '%q' "$path" ; } | xsel -bi
You may bind some key sequence to paste PRIMARY or CLIPBOARD content to
BASH prompt quoted
_bind_x_yank() {
local buffer head tail
if [ -z "$READLINE_ARGUMENT" ]
then
buffer="$(xsel --output "${1:---primary}")"
else
buffer="$(xsel --output "${1:---primary}" |
xargs --null printf '%q')"
fi
[ -n "$buffer" ] || return
head="${READLINE_LINE:0:$READLINE_POINT}${buffer}"
tail="${READLINE_LINE:$READLINE_POINT}"
READLINE_LINE="${head}${tail}"
READLINE_POINT="${#head}"
}
bind -x emacs -x '"\C-xY": _bind_x_yank'
bind -x emacs -x '"\C-xy": _bind_x_yank --clipboard'
[Esc] [1] [Ctrl+x] [y]
from clipboard or last [Y] from PRIMARY selection.
You even may define a desktop-wide shortcut that replaces selection
content with its quoted variant. Neither task requires quoted output
from realpath directly.
I am unsure what kind of debugger you use and what kind of escaping it
needs.
P.S.
A corner case is a file path having trailing newlines
https://mywiki.wooledge.org/BashPitfalls#content.3D.24.28.3Cfile.29
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 01:10 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 01:40 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 01:50 +0200
Re: realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 01:50 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 04:20 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 04:20 +0200
Re: realpath quoting Max Nikulin <manikulin@gmail.com> - 2024-05-03 05:00 +0200
Re: realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 06:40 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 13:10 +0200
Re: realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 13:40 +0200
Re: realpath quoting Sirius <sirius@trudheim.com> - 2024-05-03 13:50 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 21:20 +0200
Re: realpath quoting Max Nikulin <manikulin@gmail.com> - 2024-05-03 17:20 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 07:40 +0200
Re: realpath quoting Tom Browder <tom.browder@gmail.com> - 2024-05-04 15:30 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-04 16:00 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 07:20 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 13:10 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 20:50 +0200
Re: realpath quoting Teemu Likonen <tlikonen@iki.fi> - 2024-05-03 06:50 +0200
csiph-web