Skip to content

Commit

Permalink
Solve #169
Browse files Browse the repository at this point in the history
  • Loading branch information
amanuel2 committed Jan 17, 2017
1 parent 217826b commit 5cbf47a
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions bin/echo/opts/main_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
**/

#include <misc/status_codes.h>
#include <string/string.h>
#include <unistd/unistd.h>
Expand All @@ -35,32 +35,34 @@ int main_echo_opt_handler(char *cmd)
size_t num_opts = get_opt_count(cmd);
str_t opts[num_opts];
get_opt(cmd,opts);

char opts_one_key[strlen(opts[1].str)];

for(int i=0; opts_one_key[i]; i++) opts_one_key[i] = 0;

if(strcmp(opts[1].str , "--help")==0)
printk(cmd_echo.help);
else if(num_opts >= 2)
{
if(opts[1].str[0] == '\'' && opts[num_opts-1].str[(strlen(opts[1].str)-1)] == '\'')
if(opts[1].str[0] == '\'' && opts[num_opts-1].str[(strlen(opts[num_opts-1].str)-1)] == '\'')
{
for(size_t i=1; i<num_opts; i++)
{

for(size_t j=0; opts[i].str[j]; j++)
{
if(i==1 && j==0) j++;
if(i==(num_opts-1) && j == (strlen(opts[1].str)-1) )
{
printk("\n");
if(i==(num_opts-1) && j == (strlen(opts[num_opts-1].str)-1) )
{
printk("\n");
return STATUS_OK;
}
printk("%c" , opts[i].str[j]);
}

printk(" ");
}
return STATUS_OK;
return STATUS_OK;
}
else if(opts[1].str[0] == '\"' && opts[num_opts-1].str[(strlen(opts[1].str)-1)] == '\"')
{
Expand All @@ -70,8 +72,8 @@ int main_echo_opt_handler(char *cmd)
{
if(i==1 && j==0) j++;
if(i==(num_opts-1) && j == (strlen(opts[1].str)-1) )
{
printk("\n");
{
printk("\n");
return STATUS_OK;
}
printk("%c" , opts[i].str[j]);
Expand All @@ -85,12 +87,6 @@ int main_echo_opt_handler(char *cmd)
}
else
printk(cmd_echo.invalid_use_msg);

return STATUS_OK;
}






0 comments on commit 5cbf47a

Please sign in to comment.