Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I realize that I should not place semi-colons after each line as per the advice on my first question first questionfirst question. I forgot to make the appropriate changes to this code snippet.

I realize that I should not place semi-colons after each line as per the advice on my first question first question. I forgot to make the appropriate changes to this code snippet.

I realize that I should not place semi-colons after each line as per the advice on my first question first question. I forgot to make the appropriate changes to this code snippet.

deleted 199 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I'm new to writing bash scripts and I was wondering if I could get someone's advice on a part of the script I'm working on.

Intended purpose of code

CheckThis checks if a font is installed by using fc-list and grep, if. If the particular font is not installed, offerit offers to install it for the user. This snippet is part of a larger script that installs a particular Conky configuration along with all of its dependencies with minimal effort from the user.

  • I have to create the FONT_INSTALLED variable to avoid a "too many arguments" error by placing the code into the if statement, is there a better practice for handling this?
  • To check if the font is installed, I check if the FONT_INSTALLED variable is a null String or not, is. Is this considered good practice? I know in languages such as Java a String is normally checked for length/content since the default value is "".
  • I've seen that placing > /dev/null after a command that would normally have output hides the output. This seems slightly 'hacky' as I know commands such as wget have the -q or --quiet option to hide output. For commands that do not have such an option, what is the preferred method of hiding output?

Edit: I realize that I should not place semi-colons after each line as per the advice on my first question first question. I forgot to make the appropriate changes to this code snippet.

Here is the code that I am using:

I'm new to writing bash scripts and I was wondering if I could get someone's advice on a part of the script I'm working on.

Intended purpose of code

Check if a font is installed by using fc-list and grep, if the particular font is not installed, offer to install it for the user. This snippet is part of a larger script that installs a particular Conky configuration along with all of its dependencies with minimal effort from the user.

  • I have to create the FONT_INSTALLED variable to avoid a "too many arguments" error by placing the code into the if statement, is there a better practice for handling this?
  • To check if the font is installed, I check if the FONT_INSTALLED variable is a null String or not, is this considered good practice? I know in languages such as Java a String is normally checked for length/content since the default value is "".
  • I've seen that placing > /dev/null after a command that would normally have output hides the output. This seems slightly 'hacky' as I know commands such as wget have the -q or --quiet option to hide output. For commands that do not have such an option, what is the preferred method of hiding output?

Edit: I realize that I should not place semi-colons after each line as per the advice on my first question first question. I forgot to make the appropriate changes to this code snippet.

Here is the code that I am using:

This checks if a font is installed by using fc-list and grep. If the particular font is not installed, it offers to install it for the user. This snippet is part of a larger script that installs a particular Conky configuration along with all of its dependencies with minimal effort from the user.

  • I have to create the FONT_INSTALLED variable to avoid a "too many arguments" error by placing the code into the if statement, is there a better practice for handling this?
  • To check if the font is installed, I check if the FONT_INSTALLED variable is a null String or not. Is this considered good practice? I know in languages such as Java a String is normally checked for length/content since the default value is "".
  • I've seen that placing > /dev/null after a command that would normally have output hides the output. This seems slightly 'hacky' as I know commands such as wget have the -q or --quiet option to hide output. For commands that do not have such an option, what is the preferred method of hiding output?

I realize that I should not place semi-colons after each line as per the advice on my first question first question. I forgot to make the appropriate changes to this code snippet.

edited tags
Link
200_success
  • 145.6k
  • 22
  • 191
  • 481
Added additional information.
Source Link
John P.
  • 185
  • 6
Loading
Source Link
John P.
  • 185
  • 6
Loading