joshua-redfield / lauf

A lightweight application and task launcher programmed in the shell scripting language. Lauf is no longer being updated or improved.
http://github.com/joshua-redfield/lauf
GNU General Public License v3.0
3 stars 0 forks source link

Empty variables causing unexpected operator error #7

Closed joshua-redfield closed 13 years ago

joshua-redfield commented 13 years ago

This seems to be valid for almost every core plugin and external one. The unexpected operator error is caused by using the test statement against blank variables. Fix should be easy, variable=unset for each and every variable that's causing this error. Much like the lauf_app_options bug, there's no rush on fixing this.

somasis commented 13 years ago

i'll fix it right now.

joshua-redfield commented 13 years ago

How do you intend to do so? Most of these errors are caused by checking against lauf_exec1-lauf_exec999. Which if you set $lauf_exec2=unset will fix the error but it'll also erase what's being passed to the plugin(If there's someting in $lauf_exec2). I originally thought this was going to be an easy fix, not sure of that anymore.

joshua-redfield commented 13 years ago

Perhaps parameter substitution is the key? For example: ${lauf_exec2:=default_value}

somasis commented 13 years ago

i've never seen a problem in lauf_exec vars, but if there are ones, you could probably just add something to clear vars in the actual lauf script

EDIT: Ah, just saw the message about parameter substitution. I'll try that instead

joshua-redfield commented 13 years ago

Not sure how you haven't seen the unexpected operator error involving lauf_exec vars because I have yet to see one that isn't caused by them. Anyways parameter substition definitely solves this problem, tested them on my local branch. Simply put, every lauf_exec var needs to be substituted to a default value if the variable is emtpy.

Example: if [ ${lauf_exec2:=unset} = "-" ] && [ ! ${lauf_exec3:=unset} = "" ]; then chmod a-x "${_plugin}" lauf_notify "Plugin Deactivated:" "${_plugin}" return elif [ ${lauf_exec2:=unset} = "+" ] && [ ! ${lauf_exec3:=unset} = "" ]; then chmod a+x "${_plugin}" lauf_notify "Plugin Activated:" "${_plugin}" return elif [ ${lauf_exec2:=unset} = "--" ]; then cd $lauf_plugindir chmod a-x ._ lauf_notify "Plugin Deactivated:" "All plugins" return elif [ ${lauf_exec2:=unset} = "++" ]; then cd $lauf_plugindir chmod a+x ._ lauf_notify "Plugin Activated:" "All plugins" return fi

joshua-redfield commented 13 years ago

This no longer affects core plugins, Have yet to still convert external ones.

joshua-redfield commented 13 years ago

Fixed and closed.