mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
Fix cp and mv so 'cp foo/README bar' where foo and bar are directories,
and README is a file. -Erik
This commit is contained in:
parent
5338ce19c8
commit
1dbc17f630
@ -1,3 +1,10 @@
|
|||||||
|
0.41
|
||||||
|
* Fixed a bug in both cp and mv preventing 'cp foo/README bar'
|
||||||
|
type commands (file in a directory to another directory)
|
||||||
|
from working.
|
||||||
|
|
||||||
|
-Erik Andersen,
|
||||||
|
|
||||||
0.40
|
0.40
|
||||||
* New Apps: sort, uniq. -beppu
|
* New Apps: sort, uniq. -beppu
|
||||||
* New Apps: lsmod, rmmod -erik
|
* New Apps: lsmod, rmmod -erik
|
||||||
|
2
Makefile
2
Makefile
@ -22,7 +22,7 @@ BUILDTIME=$(shell date "+%Y%m%d-%H%M")
|
|||||||
|
|
||||||
# Comment out the following to make a debuggable build
|
# Comment out the following to make a debuggable build
|
||||||
# Leave this off for production use.
|
# Leave this off for production use.
|
||||||
DODEBUG=false
|
DODEBUG=true
|
||||||
# If you want a static binary, turn this on. I can't think
|
# If you want a static binary, turn this on. I can't think
|
||||||
# of many situations where anybody would ever want it static,
|
# of many situations where anybody would ever want it static,
|
||||||
# but...
|
# but...
|
||||||
|
@ -48,6 +48,7 @@ static int srcDirFlag = FALSE;
|
|||||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||||
{
|
{
|
||||||
char newdestName[NAME_MAX];
|
char newdestName[NAME_MAX];
|
||||||
|
char* newsrcName = NULL;
|
||||||
|
|
||||||
strcpy(newdestName, destName);
|
strcpy(newdestName, destName);
|
||||||
if ( srcDirFlag == TRUE ) {
|
if ( srcDirFlag == TRUE ) {
|
||||||
@ -62,6 +63,10 @@ static int fileAction(const char *fileName, struct stat* statbuf)
|
|||||||
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
||||||
strcat(newdestName, "/");
|
strcat(newdestName, "/");
|
||||||
}
|
}
|
||||||
|
newsrcName = strrchr(srcName, '/');
|
||||||
|
if (newsrcName && *newsrcName != '\0')
|
||||||
|
strcat(newdestName, newsrcName);
|
||||||
|
else
|
||||||
strcat(newdestName, srcName);
|
strcat(newdestName, srcName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ static int srcDirFlag = FALSE;
|
|||||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||||
{
|
{
|
||||||
char newdestName[NAME_MAX];
|
char newdestName[NAME_MAX];
|
||||||
|
char* newsrcName = NULL;
|
||||||
|
|
||||||
strcpy(newdestName, destName);
|
strcpy(newdestName, destName);
|
||||||
if ( srcDirFlag == TRUE ) {
|
if ( srcDirFlag == TRUE ) {
|
||||||
@ -50,6 +51,10 @@ static int fileAction(const char *fileName, struct stat* statbuf)
|
|||||||
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
||||||
strcat(newdestName, "/");
|
strcat(newdestName, "/");
|
||||||
}
|
}
|
||||||
|
newsrcName = strrchr(srcName, '/');
|
||||||
|
if (newsrcName && *newsrcName != '\0')
|
||||||
|
strcat(newdestName, newsrcName);
|
||||||
|
else
|
||||||
strcat(newdestName, srcName);
|
strcat(newdestName, srcName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
cp.c
5
cp.c
@ -48,6 +48,7 @@ static int srcDirFlag = FALSE;
|
|||||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||||
{
|
{
|
||||||
char newdestName[NAME_MAX];
|
char newdestName[NAME_MAX];
|
||||||
|
char* newsrcName = NULL;
|
||||||
|
|
||||||
strcpy(newdestName, destName);
|
strcpy(newdestName, destName);
|
||||||
if ( srcDirFlag == TRUE ) {
|
if ( srcDirFlag == TRUE ) {
|
||||||
@ -62,6 +63,10 @@ static int fileAction(const char *fileName, struct stat* statbuf)
|
|||||||
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
||||||
strcat(newdestName, "/");
|
strcat(newdestName, "/");
|
||||||
}
|
}
|
||||||
|
newsrcName = strrchr(srcName, '/');
|
||||||
|
if (newsrcName && *newsrcName != '\0')
|
||||||
|
strcat(newdestName, newsrcName);
|
||||||
|
else
|
||||||
strcat(newdestName, srcName);
|
strcat(newdestName, srcName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
mv.c
5
mv.c
@ -40,6 +40,7 @@ static int srcDirFlag = FALSE;
|
|||||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||||
{
|
{
|
||||||
char newdestName[NAME_MAX];
|
char newdestName[NAME_MAX];
|
||||||
|
char* newsrcName = NULL;
|
||||||
|
|
||||||
strcpy(newdestName, destName);
|
strcpy(newdestName, destName);
|
||||||
if ( srcDirFlag == TRUE ) {
|
if ( srcDirFlag == TRUE ) {
|
||||||
@ -50,6 +51,10 @@ static int fileAction(const char *fileName, struct stat* statbuf)
|
|||||||
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
if (newdestName[strlen(newdestName)-1] != '/' ) {
|
||||||
strcat(newdestName, "/");
|
strcat(newdestName, "/");
|
||||||
}
|
}
|
||||||
|
newsrcName = strrchr(srcName, '/');
|
||||||
|
if (newsrcName && *newsrcName != '\0')
|
||||||
|
strcat(newdestName, newsrcName);
|
||||||
|
else
|
||||||
strcat(newdestName, srcName);
|
strcat(newdestName, srcName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user