Skip to content

Commit

Permalink
command pwd #125
Browse files Browse the repository at this point in the history
  • Loading branch information
double-fault committed Dec 31, 2016
1 parent 05ea58d commit d459ffa
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps/sh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
**/


#include <sh/values.h>
Expand All @@ -31,7 +31,8 @@
#include <unistd/unistd.h>
#include <sh/shell.h>
#include <stdbool.h>
#include <help/help.h>
#include <help/help.h>
#include <pwd/pwd.h>
#include <sleep/sleep.h>
#include <echo/echo.h>
#include <string/string.h>
Expand All @@ -55,7 +56,7 @@ volatile struct typed_cmd cmd_active;



struct cmd_t *cmds[] =
struct cmd_t *cmds[] =
{
&cmd_clear,
&cmd_boneos_logo,
Expand All @@ -66,7 +67,8 @@ struct cmd_t *cmds[] =
&cmd_reboot,
&cmd_poweroff,
&cmd_boneshell,
&cmd_exit
&cmd_exit,
&cmd_pwd
,0
};

Expand Down
1 change: 1 addition & 0 deletions bin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CSRCS = \
echo/opts/main_echo.c \
cursor/cursor.c \
cursor/opts/main_cursor.c \
pwd/pwd.c \
boneshell/boneshell.c

LIBNAME := bin
Expand Down
66 changes: 66 additions & 0 deletions bin/pwd/pwd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
** This file is part of BoneOS.
**
** BoneOS is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
** BoneOS is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Ashish Ahuja
**
** @contributors:
** Ashish Ahuja<Fortunate-MAN>: start
**/

#include <misc/status_codes.h>
#include <sh/shell.h>
#include <drv/video/video.h>
#include <unistd/unistd.h>
#include <stdio/stdio.h>
#include <sh/values.h>
#include <pwd/pwd.h>

struct cmd_opt_t* cmd_pwd_opts[] =
{
0
};

int cmd_pwd_handler (char *cmd)
{
size_t num_opts = get_opt_count (cmd);
if (num_opts > 2)
{
printk(cmd_pwd.invalid_use_msg);
return STATUS_OK;
}
printk ("%s", VAR_PWD);
printk ("\n");
return STATUS_OK;
}

struct cmd_t cmd_pwd =
{
.name = "pwd",
.usage ="pwd",
.help = "pwd(1) \t\t\t\t BoneOS Terminal Manual \n"
"NAME : \n "
"\tpwd\n"
"SYNOPSIS : \n "
"\tpwd\n"
"DESCRIPTION : \n "
"\tPrints out the current working directory.\n",
.cmd_opts = cmd_pwd_opts,
.handler = &cmd_pwd_handler,
.invalid_use_msg = "Invalid use of pwd command.\n"
"Type in pwd --help for more help.\n",
.privilege = USER
};
1 change: 1 addition & 0 deletions include/bin/pwd/pwd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extern struct cmd_t cmd_pwd;

0 comments on commit d459ffa

Please sign in to comment.