mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
fix: prevent execute command twice
This commit is contained in:
1 parent
41a090ce73
commit
a73aa8b461
2 files changed
+2
-6
No files matched your search
@@ -15,10 +15,10 @@ preexec() {
|
|||||||
# Check if the command is in the list of interactive commands
|
# Check if the command is in the list of interactive commands
|
||||||
if [[ " ${interactive_commands[@]} " =~ " $1 " ]]; then
|
if [[ " ${interactive_commands[@]} " =~ " $1 " ]]; then
|
||||||
# If it is, just execute it normally
|
# If it is, just execute it normally
|
||||||
eval $1
|
exec
|
||||||
else
|
else
|
||||||
# If it's not, execute it and redirect its output to a file
|
# If it's not, execute it and redirect its output to a file
|
||||||
eval $1 > /tmp/cmd.out 2>/tmp/cmd.error
|
exec > >(tee /tmp/cmd.out) 2> >(tee /tmp/cmd.error >&2)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,10 @@ const commandHandler = async (session, commandInput) => {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(stage.condition)
|
|
||||||
|
|
||||||
const commandMatch = checkMatch(stage.condition.command, commandInput.command)
|
const commandMatch = checkMatch(stage.condition.command, commandInput.command)
|
||||||
const outputMatch = checkMatch(stage.condition.output, commandInput.output)
|
const outputMatch = checkMatch(stage.condition.output, commandInput.output)
|
||||||
const errorMatch = checkMatch(stage.condition.error, commandInput.output)
|
const errorMatch = checkMatch(stage.condition.error, commandInput.output)
|
||||||
|
|
||||||
console.log(commandMatch, outputMatch, errorMatch)
|
|
||||||
|
|
||||||
if (!commandMatch || !outputMatch || !errorMatch) return {}
|
if (!commandMatch || !outputMatch || !errorMatch) return {}
|
||||||
|
|
||||||
session.completion.push(session.progress)
|
session.completion.push(session.progress)
|
||||||
|
|||||||
Reference in new issue
Block a user