Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for open-remote-pipe* is misleading #39

Closed
graywolf opened this issue May 3, 2024 · 4 comments
Closed

Documentation for open-remote-pipe* is misleading #39

graywolf opened this issue May 3, 2024 · 4 comments
Assignees
Labels
topic/documentation Documentation issues.

Comments

@graywolf
Copy link

graywolf commented May 3, 2024

The documentation claims

 -- Scheme Procedure: open-remote-pipe* session mode prog [args...]
     Execute PROG on the remote host with the given ARGS using a SESSION
     with a pipe to it.  Returns newly created channel port with the
     specified MODE.

However what is actually executed is the equivalent of (string-append prog " " (string-join args " ")). That is quite surprising, given the signature of the procedure, so I believe it should be documented.

Working around it (and getting actual equivalent of open-pipe*) is not hard, but one has to know it is necessary and I find that somewhat hard to figure out from the current documentation.

@artyom-poptsov artyom-poptsov self-assigned this May 3, 2024
@artyom-poptsov artyom-poptsov added the topic/documentation Documentation issues. label May 3, 2024
@artyom-poptsov
Copy link
Owner

Hello!

Yes, currently open-remote-pipe* literally does this:

(open-remote-pipe session (string-join (cons prog args)) mode)

It's not clear for me what do you expect from the procedure. Could you please share your workaround? Maybe that way I can better understand how to fix the documentation (or the procedure itself, for that matter.)

Thanks,
-avp

@graywolf
Copy link
Author

graywolf commented May 3, 2024

Hi :)

It's not clear for me what do you expect from the procedure. Could you please share your workaround?

Sure, I would have expected (open-remote-pipe* "ls" "-la" "/foo bar") to list details about a file /foo bar, the same way local (open-pipe* "ls" "-la" "/foo bar") would.

My workaround is:

(define (shell-quote s)
  "Quote string S for sh-compatible shells."
  (string-append "'" (string-replace-substring s "'" "'\\''") "'"))

(apply open-remote-pipe* session OPEN_BOTH
                     (shell-quote prog) (map shell-quote args))

That seems to do what I need, as long as there is POSIX-compatible shell on the other end.

artyom-poptsov added a commit that referenced this issue Aug 23, 2024
Change (ssh popen) procedures to make their behavior match the behavior of
"open-pipe*" procedure.

Reported by graywolf in
<#39>

* modules/ssh/popen.scm (string-replace-substring): New procedure.
(shell-quote): New procedure.
(open-remote-pipe*, open-remote-input-pipe*, open-remote-output-pipe*): Use
"shell-quote" to quote arguments to make procedures behavior match the
"open-pipe*" behavior.
* tests/common.scm (start-server/exec): Update.
* NEWS: Update.
@artyom-poptsov
Copy link
Owner

Hello!

I pushed changes that address this issue as 7a6c86f

Please check if it works for you.

Thanks,
-avp

@graywolf
Copy link
Author

Can confirm the commit does work, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/documentation Documentation issues.
Projects
None yet
Development

No branches or pull requests

2 participants