Fixed a bug when using "--" on the command line

This commit is contained in:
Pierre Pronchery 2009-10-19 21:46:30 +00:00
parent 7ca743c1dc
commit 70aec3c187

View File

@ -1,5 +1,5 @@
/* $Id$ */
/* Copyright (c) 2007 Pierre Pronchery <khorben@defora.org> */
/* Copyright (c) 2009 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Unix utils */
/* utils is not free software; you can redistribute it and/or modify it under
* the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
@ -27,11 +27,11 @@ static int _echo(int argc, char * argv[])
if(argc != 0)
{
printf("%s", argv[0]);
fputs(argv[0], stdout);
for(i = 1; i < argc; i++)
printf(" %s", argv[i]);
}
fputc('\n', stdout);
putchar('\n');
return 0;
}
@ -55,5 +55,5 @@ int main(int argc, char * argv[])
default:
return _usage();
}
return _echo(argc - 1, &argv[1]);
return _echo(argc - optind, &argv[optind]);
}