SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Sorry if this is elementary, but I want to clearly understand what this is doing:
Code:
if [ -x /usr/bin/update-desktop-database ]; then
/usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
fi
if [ -x /usr/bin/update-mime-database ]; then
/usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi
I understand that
Code:
/dev/null 2>&1
is saying, "ignore the Standard Error and Standard Out for the two programs respectively", but under what condition? And why? Is "-x" debug?
"if [ -x file ]; then" means that the command inside the if statement will occur if file exists and is executable. The ">/dev/null 2>&1" just means that the output of the command will be sent to nowhere.
Sorry if this is elementary, but I want to clearly understand what this is doing:
Is "-x" debug?
See "man test" too: -x means: if file "exist AND is executable", so it tests if the two update programs can be executed and if so it executes them, without showing any output (or errors).
Ok, so -x we test if database program is present and is executable. If yes, we update it. If no, we ignore it. Neither route raises an error or shows output. Is this accurate?
And just for my own clarity, in what scenarios would I NOT use this doinst.sh script? It seems pretty useful across the board.
Ok, so -x we test if database program is present and is executable. If yes, we update it. If no, we ignore it. Neither route raises an error or shows output. Is this accurate?
Yes
Quote:
And just for my own clarity, in what scenarios would I NOT use this doinst.sh script? It seems pretty useful across the board.
In no scenario. You won't need these updates if you do never choose an application to start based on a .desktop file's content or a mime type, but even in this case running the doinst.sh is harmless.
I just want to point out that '-x' is not true with only files, it will also be true with directories that are executable (755). It would probably be safer to check both '-f' and '-x' to make sure its an executable file, but in practice it mostly doesn't matter.
it will also be true with directories that are executable (755).
All directories are executable (or rather searchable, that's what the "x" means for directory files), so -e (exists) and -x are indistinguable for directories (or should be).
You cannot use ls or such (no wildcards like * or ? either) on directories that are NOT searchable (although you can open files IN it of which you already know the exact filename, that only needs the directory to be readable).
All directories are executable (or rather searchable, that's what the "x" means for directory files), so -e (exists) and -x are indistinguable for directories (or should be).
You cannot use ls or such (no wildcards like * or ? either) on directories that are NOT searchable (although you can open files IN it of which you already know the exact filename, that only needs the directory to be readable).
If you want to navigate a directory it needs to be executable, but there is no reason someone can't change the permissions for a directory with chmod where -e would match, but -x wouldn't. I think its best to use both -f and -x for executable files and -d for directories, but as I already said -x is usually enough for executable files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.