set variables in a bash script; ansi PS1 color script
I've been working on a script to choose fg and bg colors for the terminal.
I'm unsure about setting the variables in bash and if I'm even leaving the first while loop. (The program just stops.) Csh has a set x = 12 but bash in bash which would be preferable x=30 , x=30m, or x="30m" ? Code:
#!/bin/bash |
You are testing for the value of a number, so you need to enter numbers only.
Note that x=30m and x="30m" give the same result---ie a string containing the characters 3, 0, and m. You would only need the quotes if the string has spaces. |
I think it doesn't stop. Instead, it hangs inside the while loops:
Code:
while [ "$fore" != 0 ] Just a hint: to debug scripts when you are in doubt about syntax and/or shell expansion, you can try to launch the script by Code:
bash -x <scriptname> |
I would also suggest the use of a select statement to create your menu. It would be something like ...
Code:
PS3="Enter foreground color choice: " Also, you will only want the "m" character at the end of your background color. Setting a color is Code:
\e[<attribute>;<fg color>;<bg color>m |
Well the using case made the code look fabulous and run smoothly. I completely abandoned the failed attempts using while and / or if statements. I am curious to know what went wrong.
The new script (basically written by Hobbletoe): Code:
|
All times are GMT -5. The time now is 04:59 PM. |