mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Directly run the command in the shell
This commit is contained in:
parent
b13e9baf4e
commit
3896a0492a
4 changed files with 17 additions and 19 deletions
|
@ -141,8 +141,12 @@ func toggle_music():
|
||||||
|
|
||||||
func shell_test(command):
|
func shell_test(command):
|
||||||
mutex.lock()
|
mutex.lock()
|
||||||
print("go")
|
#print("go")
|
||||||
|
print(command)
|
||||||
|
var before = OS.get_ticks_msec()
|
||||||
var response = $ShellServer.send(command)
|
var response = $ShellServer.send(command)
|
||||||
print("stop")
|
var after = OS.get_ticks_msec()
|
||||||
|
print("took " + str(after-before)+" ms")
|
||||||
|
#print("stop")
|
||||||
mutex.unlock()
|
mutex.unlock()
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -53,11 +53,11 @@ func run_async_thread(shell_command):
|
||||||
for variable in env:
|
for variable in env:
|
||||||
hacky_command += "export %s='%s';" % [variable, env[variable]]
|
hacky_command += "export %s='%s';" % [variable, env[variable]]
|
||||||
|
|
||||||
hacky_command += "export PATH=\'"+game.tmp_prefix+":'\"$PATH\";"
|
#hacky_command += "export PATH=\'"+game.tmp_prefix+":'\"$PATH\";"
|
||||||
hacky_command += "cd '%s' || exit 1;" % _cwd
|
hacky_command += "cd '%s' || exit 1;" % _cwd
|
||||||
hacky_command += command
|
hacky_command += command
|
||||||
|
|
||||||
print(hacky_command)
|
#print(hacky_command)
|
||||||
|
|
||||||
var result
|
var result
|
||||||
var shell_command_internal = game.shell_test(hacky_command)
|
var shell_command_internal = game.shell_test(hacky_command)
|
||||||
|
|
|
@ -44,8 +44,8 @@ func send(text):
|
||||||
var shell_command = ShellCommand.new()
|
var shell_command = ShellCommand.new()
|
||||||
shell_command.command = text
|
shell_command.command = text
|
||||||
shell_command.output = response
|
shell_command.output = response
|
||||||
print("response:")
|
#print("response:")
|
||||||
print(response)
|
#print(response)
|
||||||
shell_command.exit_code = exit_code
|
shell_command.exit_code = exit_code
|
||||||
return shell_command
|
return shell_command
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -23,24 +23,18 @@ while(true) {
|
||||||
$socket->recv($len, 4);
|
$socket->recv($len, 4);
|
||||||
my $actual_len = unpack("L", $len);
|
my $actual_len = unpack("L", $len);
|
||||||
if ($actual_len == 0) {
|
if ($actual_len == 0) {
|
||||||
print("not connected");
|
#print("not connected");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
print("still connected");
|
#print("still connected");
|
||||||
my $s2;
|
my $s2;
|
||||||
$socket->recv($s2, $actual_len);
|
$socket->recv($s2, $actual_len);
|
||||||
|
|
||||||
print($s2);
|
#print($s2);
|
||||||
STDOUT->flush();
|
STDOUT->flush();
|
||||||
|
|
||||||
my $script;
|
|
||||||
open($script, ">", "/tmp/omgscript") or die $!;
|
|
||||||
#$s3 = 'export HOME=\'/home/blinry/.local/share/Oh My Git/tmp/\';export PATH=\'/home/blinry/.local/share/Oh My Git/tmp/:\'"$PATH";cd \'/home/blinry/.local/share/Oh My Git/tmp/repos/yours/\' || exit 1;find . -type f -not -path \'*/\\.git/*\'';
|
|
||||||
print $script $s2;
|
|
||||||
close($script);
|
|
||||||
|
|
||||||
$s = "";
|
$s = "";
|
||||||
$command = ". /tmp/omgscript" . "\necho MAGIC\n";
|
$command = $s2 . "\necho MAGIC\n";
|
||||||
print $in $command;
|
print $in $command;
|
||||||
|
|
||||||
inner_while: while (true) {
|
inner_while: while (true) {
|
||||||
|
@ -51,10 +45,10 @@ while(true) {
|
||||||
}
|
}
|
||||||
$s = $s . $line;
|
$s = $s . $line;
|
||||||
}
|
}
|
||||||
print "got complete output";
|
#print "got complete output";
|
||||||
print $s;
|
#print $s;
|
||||||
|
|
||||||
print length($s);
|
#print length($s);
|
||||||
STDOUT->flush();
|
STDOUT->flush();
|
||||||
my $send_length = pack("L", length($s));
|
my $send_length = pack("L", length($s));
|
||||||
$socket->send($send_length);
|
$socket->send($send_length);
|
||||||
|
|
Loading…
Reference in a new issue