I want to uninstall packages and reinstall them in user mode. I have a manually edited list made with flatpak list
, where the first word of the line is the complete name of the package.
I can make a script that prints the names, they are correct. I can execute flatpak uninstall
manually on those names and it works.
However, when I run the following loop (I removed the installation part for clarity), the script doesn't give me a choice and answers all the prompts in the negative:
#!/bin/bash
while read line
do
app_name=$(echo "$line" | awk '{print $1}')
flatpak uninstall --delete-data "$app_name"
done < flatpaklist.txt
And here is the kind of output I get:
ID Branch Op
1. io.github.Figma_Linux.figma_linux stable r
2. io.github.Figma_Linux.figma_linux.Locale stable r
3. org.freedesktop.Platform.GL.default 20.08 r
4. org.freedesktop.Platform.Locale 20.08 r
5. org.freedesktop.Platform.VAAPI.Intel 20.08 r
6. org.freedesktop.Platform 20.08 r
Proceed with these changes to the system installation? [Y/n]: n
Similar installed refs found for ‘org.freedesktop.Platform’:
- runtime/org.freedesktop.Platform/x86_64/20.08 (system)
- runtime/org.freedesktop.Platform/x86_64/22.08 (system)
- All of the above
Which do you want to use (0 to abort)? [0-3]: 0
error: No ref chosen to resolve matches for ‘org.freedesktop.Platform’
Similar installed refs found for ‘org.freedesktop.Platform’:
- runtime/org.freedesktop.Platform/x86_64/20.08 (system)
- runtime/org.freedesktop.Platform/x86_64/22.08 (system)
- All of the above
Which do you want to use (0 to abort)? [0-3]: 0
error: No ref chosen to resolve matches for ‘org.freedesktop.Platform’
Similar installed refs found for ‘org.freedesktop.Platform.GL.default’:
- runtime/org.freedesktop.Platform.GL.default/x86_64/22.08-extra (system)
- runtime/org.freedesktop.Platform.GL.default/x86_64/22.08 (system)
- runtime/org.freedesktop.Platform.GL.default/x86_64/21.08 (system)
- runtime/org.freedesktop.Platform.GL.default/x86_64/20.08 (system)
- All of the above
As you can see, the answer "n" or "0" has been input. But it's not from me, I got no choice.
I also tried with yes | flatpak uninstall --delete-data "$app_name"
. When a number is required, it stills automatically answers "0", and when expecting "yes" or "no", it stills answers "n".
flatpack
inherits the standard input stream of the loop. – Kusalananda Jan 09 '23 at 14:07yes
will send the stringy
to the standard input offlatpack
in the pipeline that you mention at the end. Ay
would possibly be interpreted as zero if the input routine tries to convert the letter to an integer. It should still be able to answery
to the they/n
questions though. I don't have access to a system that usesflatpack
so I can't really play around with it. The command has a--assumeyes
option, and it's unclear why you are not using it if you just want to responde affirmative to all questions. – Kusalananda Jan 09 '23 at 14:17