simonwalz / screen-save

A tool to make screen sessions persistent = survive system reboot.
MIT License
26 stars 4 forks source link

printf: %q: invalid conversion specification #1

Closed lskatz closed 2 years ago

lskatz commented 2 years ago

Thank you for this amazing repo. I get an error in the xargs invocation

printf: %q: invalid conversion specification

What is it supposed to do so that we can fix it? Thank you!

simonwalz commented 2 years ago

Hi

Thank you for your interest and encouragement.

You are refering to the following lines to read the command line (program and arguments) of a screen window. With this code I wanted to get the command line arguments in a secure way.

    WINDOW_CL="$(xargs -0 printf "%q " </proc/${WINDOW_PID}/cmdline | \
        sed -e 's/ \+$//g')"

According to man printf (see) the printf "%q" prints a "format that can be reused as shell input, escaping non-printable characters with the proposed POSIX $'' syntax."

Apparently, however, this possibility is not implemented in all Linux distributions. Which Linux distribution do you use? Do you know a better way to achive this functionality?

simonwalz commented 2 years ago

I wrote a version without using printf "%q". Can you check if this is working on your machine?

You find that version in the branch "shell-escape".

lskatz commented 2 years ago

I get a different error unfortunately

[gzu2@monolith3 screen-save]$ screen-save ANI ./tmp.save
/scicomp/home-pure/gzu2/src/screen-save/screen-save: line 58: ${i@Q}: bad substitution
/scicomp/home-pure/gzu2/src/screen-save/screen-save: line 58: ${i@Q}: bad substitution
[gzu2@monolith3 screen-save]$ screen -ls
There are screens on:
        29814.ANI       (Detached)
        64111.NWSS      (Detached)
        63857.NWSS2     (Detached)
3 Sockets in /var/run/screen/S-gzu2.
simonwalz commented 2 years ago

I have adjusted the script again and omitted to use "${i@Q}". Does it work now?

However, I would be interested to know which bash, screen and OS version you are using:

bash --version
screen --version
uname -a