From c824cc5888153fc1f51e2aa79b42ed6c60e706d1 Mon Sep 17 00:00:00 2001 From: "Suraj N. Kurapati" Date: Tue, 8 Dec 2009 10:09:34 -0800 Subject: [PATCH] allow passing prebuilt command string to launch() thanks to Armando Di Cianno for reporting this bug see http://lists.suckless.org/dev/0912/2693.html --- config.rb | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/config.rb b/config.rb index d2faadd..753a343 100644 --- a/config.rb +++ b/config.rb @@ -212,10 +212,34 @@ def find_programs *dirs end ## -# Launches the command built from the given words in the background. +# Launches the given command in the background. # -def launch *words - command = words.shelljoin +# ==== Parameters +# +# [command] +# The name or path to the program you want +# to launch. This can be a self-contained +# shell command if no arguments are given. +# +# [arguments] +# Command-line arguments for the command being launched. +# +# ==== Examples +# +# Launch a self-contained shell command (while making sure that +# the arguments within the shell command are properly quoted): +# +# launch "xmessage 'hello world' '#{Time.now}'" +# +# Launch a command with explicit arguments (while not +# having to worry about shell-quoting those arguments): +# +# launch 'xmessage', 'hello world', Time.now.to_s +# +def launch command, *arguments + unless arguments.empty? + command = [command, *arguments].shelljoin + end system "#{command} &" end