X Tutup
Skip to content

Commit 8fb5e5e

Browse files
committed
Report error if no filename is remote
1 parent 0341990 commit 8fb5e5e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/cmd/codespace/ssh.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,18 @@ users; see https://lwn.net/Articles/835962/ for discussion.
193193

194194
// Copy copies files between the local and remote file systems.
195195
// The mechanics are similar to 'ssh' but using 'scp'.
196-
func (a *App) Copy(ctx context.Context, args []string, opts cpOptions) (err error) {
196+
func (a *App) Copy(ctx context.Context, args []string, opts cpOptions) error {
197197
if len(args) < 2 {
198198
return fmt.Errorf("cp requires source and destination arguments")
199199
}
200200
if opts.recursive {
201201
opts.scpArgs = append(opts.scpArgs, "-r")
202202
}
203203
opts.scpArgs = append(opts.scpArgs, "--")
204+
hasRemote := false
204205
for _, arg := range args {
205206
if rest := strings.TrimPrefix(arg, "remote:"); rest != arg {
207+
hasRemote = true
206208
// scp treats each filename argument as a shell expression,
207209
// subjecting it to expansion of environment variables, braces,
208210
// tilde, backticks, globs and so on. Because these present a
@@ -225,6 +227,9 @@ func (a *App) Copy(ctx context.Context, args []string, opts cpOptions) (err erro
225227
}
226228
opts.scpArgs = append(opts.scpArgs, arg)
227229
}
230+
if !hasRemote {
231+
return fmt.Errorf("cp: no argument is a 'remote:' filename")
232+
}
228233
return a.SSH(ctx, nil, opts.sshOptions)
229234
}
230235

0 commit comments

Comments
 (0)
X Tutup