4

terminal cd . results in following weird error in the terminal buffer:

executing job failed: No such file or directory

The same error appears for term_start('cd .'). It doesn't matter which directory I cd to, the error doesn't change.

If I execute terminal without command, then execute cd . in the opened terminal, everything works fine.

I'm using vim8.1 include patches 1-1282 on Ubuntu 16.04.6 .

Based on help from comment and answer, I changed the command to

terminal bash -c 'cd .'

but it results in following error:

.': -c: line 0: unexpected EOF while looking for matching `''
.': -c: line 1: syntax error: unexpected end of file

buffer name of the terminal is:

!bash -c 'cd .'

If I replace the single quotes with double quotes the command works. But why?

guntbert
  • 1,245
  • 1
  • 13
  • 27
dedowsdi
  • 6,248
  • 1
  • 18
  • 31

1 Answers1

3

Based on Chris’s comments on the OP, I would make the shell do the work, using a level of indirection:

terminal bash -c "cd wherever && do_something"

The issue is that the bare :terminal command doesn’t ever execute a shell—it executes the name of the external program you give it (which, by default, happens to be the shell). So, terminal cd . tries to run a command on disk named cd. For reasons, you don’t have one, and it wouldn’t work if you did.

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65