diff options
| author | Shulhan <ms@kilabit.info> | 2023-12-14 20:23:19 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-12-14 20:23:47 +0700 |
| commit | 7c3b034fc45beac1da465984117d5948110c84e3 (patch) | |
| tree | 80e1e3b10aeaf919f3713b96047270b04fa09114 | |
| parent | 708919bfb67398ca6d0464553faf10aadc28893b (diff) | |
| download | awwan-7c3b034fc45beac1da465984117d5948110c84e3.tar.xz | |
all: make the magic line "#local" works on "local" command too
In case we have a script that manage local host and remote server,
calling "play" on "#local" lines only always open the connection to remote
server.
To minimize opening unused connections, let the "#local" command works
on both commands. Its up to user which part of lines that they want
to execute on remote or local.
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | _wui/doc/awwan.adoc | 5 | ||||
| -rw-r--r-- | session.go | 2 | ||||
| -rw-r--r-- | testdata/local/local.aww | 1 | ||||
| -rw-r--r-- | testdata/local/local_test.data | 5 |
5 files changed, 9 insertions, 6 deletions
@@ -71,7 +71,7 @@ build-awwan-test: test-integration: go test -tags=integration -c . machinectl shell awwan@awwan-test \ - /bin/sh -c "cd src; ./awwan.test -test.v" + /bin/sh -c "cd src; ./awwan.test" .PHONY: test-all test-all: diff --git a/_wui/doc/awwan.adoc b/_wui/doc/awwan.adoc index 2f091ed..e44ec32 100644 --- a/_wui/doc/awwan.adoc +++ b/_wui/doc/awwan.adoc @@ -421,8 +421,8 @@ $ sudo chown root:bin remote/dst The magic word "#local" define the command to be executed in the local environment. -This magic word only works if the script is executed using "play" command. -If the script executed using "local" command it will do nothing. +This magic word works when the script is executed using "play" or "local" +command. For example, given the following script, @@ -445,6 +445,7 @@ If the script executed with "local" command it will result to, ---- /home/client +/home/client ---- === Example @@ -472,6 +472,8 @@ func (ses *Session) executeScriptOnLocal(req *ExecRequest, pos linePosition) (er err = ExecLocal(req, stmt) case statementKindGet: err = ses.Copy(req, stmt) + case statementKindLocal: + err = ExecLocal(req, stmt) case statementKindPut: err = ses.Copy(req, stmt) case statementKindSudoGet: diff --git a/testdata/local/local.aww b/testdata/local/local.aww index 3ee69f4..2375a13 100644 --- a/testdata/local/local.aww +++ b/testdata/local/local.aww @@ -1,6 +1,5 @@ echo "hello" -## Should do nothing. #local: echo "nothing" echo "local" diff --git a/testdata/local/local_test.data b/testdata/local/local_test.data index 3fe3322..621d0b2 100644 --- a/testdata/local/local_test.data +++ b/testdata/local/local_test.data @@ -4,7 +4,8 @@ Test on "local" command. - === BEGIN: local testdata/local/local.aww 1- - --> 1: echo "hello" hello -- --> 4: #local: echo "nothing" -- --> 6: echo "local" +- --> 3: #local: echo "nothing" +nothing +- --> 5: echo "local" local - === END: local testdata/local/local.aww 1- |
