You are not logged in.

#1 2016-01-09 07:11:21

Kirkx
Member
Registered: 2015-04-16
Posts: 17

xinitrc code error: unnecessary wildcard

There seems to be a small code error in the xinitrc file:

/etc/X11/xinit/xinitrc
# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

The <for> line has two wildcards, which seems to be incorrect: /?*.sh

# incorrect wildcards
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do

# correct wildcards
for f in /etc/X11/xinit/xinitrc.d/*.sh ; do

The error is also repeated in the Wiki (Configuration section):

https://wiki.archlinux.org/index.php/Xinitrc

As explained in the Wiki when you actually want to use startx to launch a window manager you need to remove <.sh> as well. So after all corrections the line should look as follows:

for f in /etc/X11/xinit/xinitrc.d/*; do

When you look around at Google some experienced Arch users only remove <.sh> from the code, but I have found a few  examples where <?> wildcard has been removed as well:

https://searchcode.com/codesearch/view/65248629/

https://gitlab.com/ideasman42/dotfiles/ … r/.xinitrc

https://wiki.manjaro.org/index.php?titl … nitrc_File

Can some Arch experts confirm that it is ineeded an error and then we could go ahead and correct that line of code in the Wiki.

Offline

#2 2016-01-09 09:20:23

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: xinitrc code error: unnecessary wildcard

Why do you think it's incorrect? *.sh would match a file named ".sh", while ?*.sh would not -- it requires at least one character before the dot. [Edit: after removing the extension, ?* and * would mean the same thing when used for filename generation, though]

The .sh is also not necessarily incorrect. At some point one or more packages were putting scripts in the xinitrc.d directory without .sh extension and xinitrc is simpler to fix for end users because they generally have their own copy under $HOME and it's just one file instead of potentially many (belonging to different packages) in the system-wide xinitrc.d directory. As a long-term solution, either the default xinitrc (which seems the simplest solution) or the packages not using .sh extensions should be changed (if they haven't already -- the wiki could also be outdated -- I don't believe I've ever seen any scripts without .sh on my Arch installations).

Last edited by Raynman (2016-01-09 09:24:08)

Offline

#3 2016-01-09 10:15:39

Kirkx
Member
Registered: 2015-04-16
Posts: 17

Re: xinitrc code error: unnecessary wildcard

Thanks for your clarification. It's a little confusing for a new Arch user like myself. I just like to have a clean code, as much as possible. I will have to keep checking /xinitrc.d to see what scripts get installed in there over time.

Offline

#4 2016-01-09 11:22:22

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: xinitrc code error: unnecessary wildcard

Kirkx wrote:

I just like to have a clean code, as much as possible.

Well, one could argue that a simple "*" is cleaner than "?*.sh" and I don't see why there should be files in that directory that are not meant to be sourced and should thus be excluded by this pattern -- and with the -x test in the loop, one could actually still achieve that by making such files non-executable.

Offline

Board footer

Powered by FluxBB