Strange behaviour when I forgot to use backticks

[Putting under Plasma because I can’t see a suitable subject, and I use Plasma <grin>]

Trying to get the PID of systemsettings, I forgot to use the backticks, so just typed:

pid=pgrep systemsettings

Weird effect: this raised the systemsettings window and gave it focus.

Playing around, it’s the same whatever program I choose and I get the same behaviour with zsh, ksh and bash. It’s also the same whether I type it in konsole or xterm.

In a way, this is actually quite useful, but I wonder if anyone can explain why this is happening (and whether or not it’s a designed-in feature of pgrep).

It has nothing to do with pgrep, but rather with a bug in the biological unit between the keyboard and the chair. :stuck_out_tongue:

Just look at your command. The first section of your command is where you are assigning the value “pgrep” to a variable called pid, and then you are using that in the second part of your command as an environment variable for invoking systemsettings. Given that the system knows that systemsettings is already running, it brings the already running instance to the foreground instead of starting a new instance.


1 Like

Of course! That makes perfect sense. Thanks.

I’m even more stupid than I thought…

1 Like

It’s from all that beer, you know… :stuck_out_tongue:

“Als de drank is in de man, is de wijsheid in de kan.”

Kid making a funny face

A look-a-like?

1 Like

The syntax is either
Var=command... (this was supposed to be in backticks but the forum converts them)
The latter is the more modern variant, but tick are not deprecated.

All true, but that is not what @beermad sought to achieve. All he wanted was to discover the PID of systemsettings. :point_down:

ps -aux | grep systemsettings | grep -v grep


This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.