0

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’:

   1) runtime/org.freedesktop.Platform/x86_64/20.08 (system)
   2) runtime/org.freedesktop.Platform/x86_64/22.08 (system)
   3) 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’:

   1) runtime/org.freedesktop.Platform/x86_64/20.08 (system)
   2) runtime/org.freedesktop.Platform/x86_64/22.08 (system)
   3) 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’:

   1) runtime/org.freedesktop.Platform.GL.default/x86_64/22.08-extra (system)
   2) runtime/org.freedesktop.Platform.GL.default/x86_64/22.08 (system)
   3) runtime/org.freedesktop.Platform.GL.default/x86_64/21.08 (system)
   4) runtime/org.freedesktop.Platform.GL.default/x86_64/20.08 (system)
   5) 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".

Cormor
  • 1
  • 3
    Remember that `flatpack` inherits the standard input stream of the loop. – Kusalananda Jan 09 '23 at 14:07
  • 1
    `yes` will send the string `y` to the standard input of `flatpack` in the pipeline that you mention at the end. A `y` would possibly be interpreted as zero if the input routine tries to convert the letter to an integer. It should still be able to answer `y` to the the `y/n` questions though. I don't have access to a system that uses `flatpack` 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
  • 1
    see also [Why the behavior of while loop and for loop is different?](https://unix.stackexchange.com/questions/56876/why-the-behavior-of-while-loop-and-for-loop-is-different) – steeldriver Jan 09 '23 at 14:43
  • Does this answer your question? [Why the behavior of while loop and for loop is different?](https://unix.stackexchange.com/questions/56876/why-the-behavior-of-while-loop-and-for-loop-is-different) – tripleee Jan 09 '23 at 16:51

0 Answers0