Monday 15 April 2013

linux - Is there a syntax error in this Bash function? Functionality works fine when hardcoded into main loop -


After

I have a function that provides an element of tagging workspace [i] a corrosponding " For example, if the name of the workspace [3] is "Firefox", it will underline the name "Firefox", and if not, then no one will be underlined. Work outside of the ceremony, and inside the main , while the loop works perfectly, like:

  #dummy work for workspace_raw [i] workspace_raw [1] ] = Firefox function without boolean_check # code = to false ((i = 0; i & lt; = 15; i ++)) to workstations [i] = "$ {workspace_raw [i]}" if [ "$ { workstations [i]} "= =" Firefox "] so boolean_check = true some false fi, then $ boolean_check so workspace_firefox =" \ u3firefox \ u0 "and workspace_firefox =" \ u0firefox \ u0 "fi  < / Pre> 

However, put the functionality inside a function and It is absolutely nothing to call with logic, but there is no error even displaying this code I am using with the function, and it does not work:

  # dummy work for $ workspace_raw [i] workspace_raw [1] = Firefox # function assigned name for the logic Tag_name1 = firefox # function assign_workspace () {tag = $ 1 boolean_check = ([i = 0; i & lt; = 15 ; I work for ++) [i] = "$ {workspace_raw [i]}" if [ "$ $ {Workspaces [i]}" == "$ tag"] so Bulian_chek = right and wrong that $ Boolean_check then works Pes_ shall declare the $ tag = "\ u3test $ tag \ u0" and other verticals _ $ tag = "\ u0test announced $ tag \ u0" fi} # call with the logic function $ work_workspace $ tag_name1  < / Pre> 

Do not know what to do because the function's code works when there is a hardcode in the main loop, I think I'm making a syntax error in the code. If necessary, the complete script is:

Thanks for the help!

declare , by default, a local variable If you want the workspace_ $ tag variable available outside of that function, use the -g flag.

  if $ boolean_check ruled in -g workspace_ $ tag = "\ u3test $ tag \ U0" and G workspace_ announced $ tag = "\ u0test $ tag \ U0" fi    

No comments:

Post a Comment