In a script, command (zypper) does not return when finished

Hello.

From command line, the following command return when finished :

user_install@15:~> echo "sudo zypper rm -t pattern  kde_pim"
sudo zypper rm -t pattern  kde_pim
user_install@15:~> RET_CODE=0
user_install@15:~> sudo zypper rm -t pattern  kde_pim
[sudo] password for root: 
aSorry, try again.
[sudo] password for root: 
Reading installed packages...
'kde_pim' not found in package names. Trying capabilities.
No provider of 'kde_pim' found.
Resolving package dependencies...
Nothing to do.
user_install@15:~> 

Running within a script, the command does not return (set -x is in use) :

+ echo 'sudo zypper rm -t pattern  kde_pim'
sudo zypper rm -t pattern  kde_pim
+ RET_CODE=0
+ sudo zypper rm -t pattern kde_pim
Reading installed packages...
'kde_pim' not found in package names. Trying capabilities.
No provider of 'kde_pim' found.
Resolving package dependencies...
Nothing to do.

PS : kde-pim in not installed and is lock ( this is a normal situation for me )

Any help is welcome.

Try using the non-interactive mode with zypper (-n or --non-interactive):

sudo zypper -n rm -t pattern kde_pim

It is rather unclear what you do. Show your script, show complete copy-paste of running your script including any shell prompts.

There were a **set -e** somewhere in my script (I forgot it ).
zypper return a 104 code when a package is not found.
I keep “set -e” and I modify my script accordingly.
No more problems.
Sorry for the inconvenience.
Thank you all for your help.