[GRASS-dev] [GRASS GIS] #2152: cd command does not work in GUI Command console
GRASS GIS
trac at osgeo.org
Wed Mar 26 13:17:19 PDT 2014
#2152: cd command does not work in GUI Command console
---------------------------------+------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: 6.4.3
Keywords: cd, command console | Platform: All
Cpu: Unspecified |
---------------------------------+------------------------------------------
Changes (by wenzeslaus):
* type: defect => enhancement
* milestone: 6.4.4 => 7.0.0
Comment:
Testing `cd` command in Python outside GRASS session:
{{{
>>> import subprocess
>>> subprocess.call(['cd', '--help'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
}}}
While `cp --help` works. So, using `which` to find first `cp` and then
`cd`:
{{{
$ which cp
/bin/cp
$ echo $?
0
$ which cd
$ echo $?
1
}}}
There is really no `cd` executable. Checking `cp` and `cd` error message
style in command line:
{{{
$ cp aa
cp: missing destination file operand after `aa'
Try `cp --help' for more information.
$ cd aa
bash: cd: aa: No such file or directory
}}}
`cd` is part of bash, not a separate command. So, GUI needs to implement
its own `cd` command using Python (`os.chdir(path)`). There is a change
working directory item in the menu, so it might be enough just to connect
`cp some/path` to the same handler in the similar way as `d.*` commands
are handled. Some syntax pitfalls may occur especially on MS Windows and
with white space and non-ASCII characters.
With the new understanding of the problem, changing to enhancement.
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2152#comment:6>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list