mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Further improve accuracy of cd builtins error messages. Now correctly reports rotten symlinks.
darcs-hash:20070920175243-75c98-e210034c7bfc8308be9e03017a5a0d8ef7648b9c.gz
This commit is contained in:
parent
3b39b1fa03
commit
607e970659
3 changed files with 32 additions and 8 deletions
11
builtin.c
11
builtin.c
|
@ -2331,8 +2331,17 @@ static int builtin_cd( wchar_t **argv )
|
||||||
_( L"%ls: The directory '%ls' does not exist\n" ),
|
_( L"%ls: The directory '%ls' does not exist\n" ),
|
||||||
argv[0],
|
argv[0],
|
||||||
dir_in );
|
dir_in );
|
||||||
|
}
|
||||||
|
else if( errno == EROTTEN )
|
||||||
|
{
|
||||||
|
sb_printf( sb_err,
|
||||||
|
_( L"%ls: '%ls' is a rotten symlink\n" ),
|
||||||
|
argv[0],
|
||||||
|
dir_in );
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sb_printf( sb_err,
|
sb_printf( sb_err,
|
||||||
_( L"%ls: Unknown error trying to locate directory '%ls'\n" ),
|
_( L"%ls: Unknown error trying to locate directory '%ls'\n" ),
|
||||||
argv[0],
|
argv[0],
|
||||||
|
|
8
path.c
8
path.c
|
@ -217,6 +217,14 @@ wchar_t *path_get_cdpath( void *context, wchar_t *dir )
|
||||||
err = ENOTDIR;
|
err = ENOTDIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( lwstat( whole_path, &buf ) == 0 )
|
||||||
|
{
|
||||||
|
err = EROTTEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free( whole_path );
|
free( whole_path );
|
||||||
}
|
}
|
||||||
free( path_cpy );
|
free( path_cpy );
|
||||||
|
|
19
path.h
19
path.h
|
@ -9,6 +9,8 @@
|
||||||
#ifndef FISH_PATH_H
|
#ifndef FISH_PATH_H
|
||||||
#define FISH_PATH_H
|
#define FISH_PATH_H
|
||||||
|
|
||||||
|
#define EROTTEN 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the user configuration directory for fish. If the directory
|
Returns the user configuration directory for fish. If the directory
|
||||||
or one of it's parents doesn't exist, they are first created.
|
or one of it's parents doesn't exist, they are first created.
|
||||||
|
@ -28,11 +30,17 @@ wchar_t *path_get_config( void *context);
|
||||||
wchar_t *path_get_path( void *context, const wchar_t *cmd );
|
wchar_t *path_get_path( void *context, const wchar_t *cmd );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the full path of the specified directory. If the \c in is a
|
Returns the full path of the specified directory, using the CDPATH
|
||||||
full path to an existing directory, a copy of the string is
|
variable as a list of base directories for relative paths. The
|
||||||
returned. If \c in is a directory relative to one of the
|
returned string is allocated using halloc and the specified
|
||||||
directories i the CDPATH, the full path is returned. If no
|
context.
|
||||||
directory can be found, 0 is returned.
|
|
||||||
|
If no valid path is found, null is returned and errno is set to
|
||||||
|
ENOTDIR if at least one such path was found, but it did not point
|
||||||
|
to a directory, EROTTEN if a arotten symbolic link was found, or
|
||||||
|
ENOENT if no file of the specified name was found. If both a rotten
|
||||||
|
symlink and a file are found, it is undefined which error status
|
||||||
|
will be returned.
|
||||||
|
|
||||||
\param in The name of the directory.
|
\param in The name of the directory.
|
||||||
\param context the halloc context to use for memory allocations
|
\param context the halloc context to use for memory allocations
|
||||||
|
@ -40,7 +48,6 @@ wchar_t *path_get_path( void *context, const wchar_t *cmd );
|
||||||
*/
|
*/
|
||||||
wchar_t *path_get_cdpath( void *context, wchar_t *in );
|
wchar_t *path_get_cdpath( void *context, wchar_t *in );
|
||||||
|
|
||||||
|
|
||||||
wchar_t *path_make_canonical( void *context, const wchar_t *path );
|
wchar_t *path_make_canonical( void *context, const wchar_t *path );
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue