0

Why is lets say HOME recognized by all my scripts but my variable DMENU isn't? I export it in my bspwmrc file which is executed at start up.Also had it in my zshrc.

Why do this?

DMENU="-h 27 -z 940 -y 4 -x 210 -i"

I want to have this variable in my scripts so if later I want to change something I don't have to manually change all my scripts.

Could it be that the shebang is #!/bin/sh pointing to dash ? How do i set a global variable then?

2
  • I think not. The post doesn't specify for dash looking at the man page it said to use the .profile file in the home directory. I created one and added ` export DMENU="-h 27 -z 900 -y 4 -x 220 -i" ` to it. Running echo $DMENU returns nothing. Is there a dependency to the .profile file , an XDG package perhaps,a reboot?
    – Lampros
    Commented Jun 6, 2021 at 17:45
  • 1
    The linked duplicate covers .profile and applies to all shells, it is in fact a duplicate.
    – jesse_b
    Commented Jun 6, 2021 at 20:42

1 Answer 1

0

Creating a .profile file and exporting my variable there seems to have fixed it. Also bonus for anyone trying something like this, when giving arguments to programs like this make sure to do it like this

dmenu $(echo "$DMENU")

otherwise it doesn't really accept them as arguments.

3
  • How does "dmenu $DMENU" not work?
    – waltinator
    Commented Jun 6, 2021 at 18:34
  • @waltinator, as $DMENU is a scalar variable, not an array, in zsh, rc, fish and other sane shells, dmenu $DMENU calls dmenu with one argument: the contents of $DMENU. If you want to split the contents on space characters, you need dmenu ${(s[ ])DMENU} or dmenu $=DMENU to split on any $IFS character instead of spaces. dmenu $(echo "$DMENU") also works as IFS-splitting is done upon command substitution in zsh. dmenu $DMENU does IFS-splitting in bash/dash and most other Bourne-like shells but also globbing, though that's generally seen as a misfeature. Commented Jun 7, 2021 at 7:29
  • wow thanks, didn't know that! So dmenu ${(s[,])DMENU} will set the delimiter as , ? Where can i find more documentation on this and the $= you mentioned?
    – Lampros
    Commented Jun 7, 2021 at 14:34

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.