La question suivante concerne une réponse qui a été affichée sur this question:Comment est-ce que je peux me débarasser de cette sortie d'osascript?
J'aime l'idée de créer ma propre fonction qui ouvre un nouveau terminal, de sorte que le script Craig Walker lié à cette question susmentionnée convenait à mon Besoins. Le scénario, écrit par Mark Liyanage, se trouve here.
Ce script est la suivante:
#!/bin/sh
#
# Open a new Mac OS X terminal window with the command given
# as argument.
#
# - If there are no arguments, the new terminal window will
# be opened in the current directory, i.e. as if the command
# would be "cd `pwd`".
# - If the first argument is a directory, the new terminal will
# "cd" into that directory before executing the remaining
# arguments as command.
# - If there are arguments and the first one is not a directory,
# the new window will be opened in the current directory and
# then the arguments will be executed as command.
# - The optional, leading "-x" flag will cause the new terminal
# to be closed immediately after the executed command finishes.
#
# Written by Marc Liyanage <http://www.entropy.ch>
#
# Version 1.0
#
if [ "x-x" = x"$1" ]; then
EXIT="; exit"; shift;
fi
if [[ -d "$1" ]]; then
WD=`cd "$1"; pwd`; shift;
else
WD="'`pwd`'";
fi
COMMAND="cd $WD; [email protected]"
#echo "$COMMAND $EXIT"
osascript 2>/dev/null <<EOF
tell application "Terminal"
activate
do script with command "$COMMAND $EXIT"
end tell
EOF
J'ai fait un changement au script sur le site lié; J'ai commenté la ligne qui sort "$ COMMAND $ EXIT" pour éliminer une certaine verbosité. Cependant, quand je lance le script que je reçois encore cette sortie
tab 1 of window id 2835
juste avant qu'il ouvre la nouvelle fenêtre et exécute la commande que je passe. Toutes les idées pourquoi cela se produirait? (J'essayé de déplacer la redirection de stderr vers/dev/null avant l'appel à oascript, mais cela n'a fait aucune différence.)
Fonctionne comme un charme. Le script original avait osascript 2>/dev/null << EOF qui redirigeait stderr vers/dev/null, c'est pourquoi je l'ai déplacé. Je n'ai pas pensé à essayer de rediriger la sortie régulière vers/dev/null ... Merci! – barclay