Skip to main content
added 62 characters in body
Source Link
l0b0
  • 9k
  • 21
  • 36

Bugs:

  • echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do my_command <<< "$my_variable" instead.
  • unset $IFS does not unset IFS. For that you need unset IFS.

Simplifications:

  • You shouldn't need to set IFS - read will save the full input to the variable anyway (see help [r]ead).
  • A lot of the code is already Python, and Python has much fewer caveats than Bash, so changing to it would very much benefit the maintainability of the code. Strictly speaking it's not a pure Bash script anyway, and you really don't want to be parsing JSON manually in Bash. If you really need a Bash script (which you shouldn't unless it's for a Bash programming exercise, and even then, somebody is wrong on the Internet if they asked you to use pure Bash to parse JSON) you could make it a wrapper script.
  • Bash's read takes a -p prompt option, so you can avoid the first printf.
  • Unchanging variables such as URL should be assigned outside of the loop.

Style issues:

  • Non-exported variables should be lowercase to distinguish them from exported variables.
  • It is customary to exit with a non-zero exit code when a command fails.

Bugs:

  • echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do my_command <<< "$my_variable" instead.
  • unset $IFS does not unset IFS. For that you need unset IFS.

Simplifications:

  • You shouldn't need to set IFS - read will save the full input to the variable anyway (see help [r]ead).
  • A lot of the code is already Python, and Python has much fewer caveats than Bash, so changing to it would very much benefit the maintainability of the code.
  • Bash's read takes a -p prompt option, so you can avoid the first printf.
  • Unchanging variables such as URL should be assigned outside of the loop.

Style issues:

  • Non-exported variables should be lowercase to distinguish them from exported variables.
  • It is customary to exit with a non-zero exit code when a command fails.

Bugs:

  • echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do my_command <<< "$my_variable" instead.
  • unset $IFS does not unset IFS. For that you need unset IFS.

Simplifications:

  • You shouldn't need to set IFS - read will save the full input to the variable anyway (see help [r]ead).
  • A lot of the code is already Python, and Python has much fewer caveats than Bash, so changing to it would very much benefit the maintainability of the code. Strictly speaking it's not a pure Bash script anyway, and you really don't want to be parsing JSON manually in Bash. If you really need a Bash script (which you shouldn't unless it's for a Bash programming exercise, and even then, somebody is wrong on the Internet if they asked you to use pure Bash to parse JSON) you could make it a wrapper script.
  • Bash's read takes a -p prompt option, so you can avoid the first printf.
  • Unchanging variables such as URL should be assigned outside of the loop.

Style issues:

  • Non-exported variables should be lowercase to distinguish them from exported variables.
  • It is customary to exit with a non-zero exit code when a command fails.
added 62 characters in body
Source Link
l0b0
  • 9k
  • 21
  • 36

Possible bugsBugs:

  • echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do my_command <<< "$my_variable" instead.
  • unset $IFS does not unset IFS. For that you need unset IFS.

Simplifications:

  • You shouldn't need to set IFS - read will save the full input to the variable anyway (see help [r]ead).
  • A lot of the code is already Python, and Python has much fewer caveats than Bash, so changing to it would very much benefit the maintainability of the code.
  • Bash's read takes a -p prompt option, so you can avoid the first printf.
  • Unchanging variables such as URL should be assigned outside of the loop.

Style issues:

  • Non-exported variables should be lowercase to distinguish them from exported variables.
  • It is customary to exit with a non-zero exit code when a command fails.

Possible bugs:

  • echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do my_command <<< "$my_variable" instead.

Simplifications:

  • You shouldn't need to set IFS - read will save the full input to the variable anyway (see help [r]ead).
  • A lot of the code is already Python, and Python has much fewer caveats, so changing to it would very much benefit the maintainability of the code.
  • Bash's read takes a -p prompt option, so you can avoid the first printf

Style issues:

  • Non-exported variables should be lowercase to distinguish them from exported variables.
  • It is customary to exit with a non-zero exit code when a command fails.

Bugs:

  • echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do my_command <<< "$my_variable" instead.
  • unset $IFS does not unset IFS. For that you need unset IFS.

Simplifications:

  • You shouldn't need to set IFS - read will save the full input to the variable anyway (see help [r]ead).
  • A lot of the code is already Python, and Python has much fewer caveats than Bash, so changing to it would very much benefit the maintainability of the code.
  • Bash's read takes a -p prompt option, so you can avoid the first printf.
  • Unchanging variables such as URL should be assigned outside of the loop.

Style issues:

  • Non-exported variables should be lowercase to distinguish them from exported variables.
  • It is customary to exit with a non-zero exit code when a command fails.
Source Link
l0b0
  • 9k
  • 21
  • 36

Possible bugs:

  • echo "$my_variable" | my_command can behave unexpectedly if the variable starts with one of the echo options. You can do my_command <<< "$my_variable" instead.

Simplifications:

  • You shouldn't need to set IFS - read will save the full input to the variable anyway (see help [r]ead).
  • A lot of the code is already Python, and Python has much fewer caveats, so changing to it would very much benefit the maintainability of the code.
  • Bash's read takes a -p prompt option, so you can avoid the first printf

Style issues:

  • Non-exported variables should be lowercase to distinguish them from exported variables.
  • It is customary to exit with a non-zero exit code when a command fails.