Re: [dev] [dmenu] unwanted behaviour when feeded from stdin

From: Quentin Rameau <>
Date: Sat, 21 Nov 2020 20:49:24 +0100

> Hi list,

Hi Damien,

> I am heavily using dmenu to feed editor with external shell scripts
> when writing *TeX files. Since dmenu 4.9, I noticed a new, and
> somehow annoying, behaviour: when dmenu is called from STDIN
> twice in a row, the scripts hangs, waiting for input from the shelle
> and I have to type ^D to get the script running further on.
> Looks like it doesn't happen when dmenu is reading a file.
> Here is a basic MWE:
> #!/bin/ksh
> Orientation=$(echo "horizontal\nvertical"|dmenu)
> #here the cursor goes back to the shell and I
> #have to type Ctr-D to have the script running further on
> NbLignes=$(dmenu -p "nombre de lignes")
> echo "tableau: $Orientation de $NbLignes lignes"
> I experienced this on both st and xterm on OpenBSD.
> What can I do to avoid this behaviour?

This is how dmenu works, it reads data from stdin, and then asks the
user do make a choice about them.
This isn't a question of calling dmenu twice, this is about you calling
dmenu without input in: dmenu -p "nombre de lignes".
So dmenu waits for its input from stdin, you close that with ^D, that's
expected behaviour.

I suppose you were intending something like
NbLignes=$(dmenu -p "nombre de lignes" < /dev/null) instead
Received on Sat Nov 21 2020 - 20:49:24 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 21 2020 - 21:00:09 CET