"Filename argument required" warning when running shell command from bash_profile
Remove the .
lines:
scratchpad(){
if [ $1 = run ]; then
ruby ~/Programming/ruby/scratchpad.rb
else
open -a $1 ~/Programming/ruby/scratchpad.rb
fi
}
In the shell, .
is a builtin command in its own right, an alias for "source", which is used to read in a shell script and execute its commands in the current shell rather than spawning a subshell, typically used for scripts that set environment variables that you want to use later
. set_env.sh
The error message you get is complaining that you haven't provided the file name argument that the .
command expects.
Comments
-
RobertAKARobin almost 2 years
I'm customizing my .bash_profile in my Mac's Terminal. I want to make a function that either runs a ruby file or opens it in a text editor, depending on my arguments.
I'm very new to doing anything more with Terminal than just installing stuff.
Here's what I've got so far:
scratchpad(){ if [ $1 = run ]; then ruby ~/Programming/ruby/scratchpad.rb . else open -a $1 ~/Programming/ruby/scratchpad.rb . fi }
It works, successfully opening or running the script, but it gives me this error:
-bash: .: filename argument required .: usage: . filename [arguments]