diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-09 20:16:26 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-09 20:16:26 -0800 |
commit | f92b24221a1b2449b17161d57ae1b4699b82374b (patch) | |
tree | eaba7e3031b7a9494da0a6cda68d11b66935b0f1 /builtin.cpp | |
parent | afd78f3f0b973e281db5b78e4d5851f36a32988f (diff) |
Made pwd a builtin
Fixed a thread error when autosuggesting with a command substitution
Diffstat (limited to 'builtin.cpp')
-rw-r--r-- | builtin.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/builtin.cpp b/builtin.cpp index 57c53d79..a4840360 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1470,6 +1470,19 @@ static int builtin_echo( parser_t &parser, wchar_t **argv ) return STATUS_BUILTIN_OK; } +/** The pwd builtin. We don't respect -P to resolve symbolic links because we try to always resolve them. */ +static int builtin_pwd( parser_t &parser, wchar_t **argv ) +{ + wchar_t dir_path[4096]; + wchar_t *res = wgetcwd( dir_path, 4096 ); + if (res == NULL) { + return STATUS_BUILTIN_ERROR; + } else { + stdout_buffer.append(dir_path); + stdout_buffer.push_back(L'\n'); + return STATUS_BUILTIN_OK; + } +} /** The function builtin, used for providing subroutines. @@ -3601,6 +3614,7 @@ static const builtin_data_t builtin_datas[]= { L"jobs", &builtin_jobs, N_( L"Print currently running jobs" ) }, { L"not", &builtin_generic, N_( L"Negate exit status of job" ) }, { L"or", &builtin_generic, N_( L"Execute command if previous command failed" ) }, + { L"pwd", &builtin_pwd, N_( L"Print the working directory" ) }, { L"random", &builtin_random, N_( L"Generate random number" ) }, { L"read", &builtin_read, N_( L"Read a line of input into variables" ) }, { L"return", &builtin_return, N_( L"Stop the currently evaluated function" ) }, |