Commit de22dd53 authored by Seblu's avatar Seblu
Browse files

work on execution

work on variables
work on functions
parent cf642cb2
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -21,8 +21,10 @@ bin_PROGRAMS=42sh
		src/builtin/builtin.c			\
		src/builtin/builtin_exit.c		\
		src/common/basename.c			\
		src/common/common.h			\
		src/common/constant.h			\
		src/common/env.c			\
		src/common/function.h			\
		src/common/getcwd2.c			\
		src/common/isdigitstr.c			\
		src/common/macro.h			\
		src/common/strmerge.c			\
@@ -39,21 +41,24 @@ bin_PROGRAMS=42sh
		src/exec/exec_sep.c			\
		src/exec/exec_sepand.c			\
		src/exec/exec_while.c			\
		src/parser/alias.h			\
		src/parser/alias.c			\
		src/parser/getline.h			\
		src/parser/alias.h			\
		src/parser/getline.c			\
		src/parser/parser.h			\
		src/parser/getline.h			\
		src/parser/parser.c			\
		src/parser/parser.h			\
		src/parser/lexer.c			\
		src/shell/func.c			\
		src/shell/func.h			\
		src/shell/getoptions.c			\
		src/shell/option.h			\
		src/shell/option.c			\
		src/shell/option.h			\
		src/shell/shell.c			\
		src/shell/shell.h			\
		src/shell/shell_entry.c			\
		src/shell/shell_init.c			\
		src/shell/shell_destroy.c		\
		src/shell/prompt.c
		src/shell/prompt.c			\
		src/shell/var.c				\
		src/shell/var.h


CLEANFILES= *~ \#*\#

README

0 → 100644
+3 −0
Original line number Diff line number Diff line
42sh

This program was written by Sebastien Luttringer aka Seblu
+2 −12
Original line number Diff line number Diff line
@@ -98,16 +98,6 @@ AC_ARG_WITH([noerror],
  ]
)

AC_ARG_WITH([dynamic],
  [AS_HELP_STRING([--with-dynamic], [Compiling with dynamic libraries])],
  [dnl action-if-given
       dynamic=true
  ],
  [dnl action-if-not-given
       dynamic=false
  ]
)

AC_ARG_WITH([debug],
  [AS_HELP_STRING([--with-debug], [use -g and don't use -DNDEBUG -O3])],
  [dnl action-if-given
@@ -125,7 +115,7 @@ AC_ARG_WITH([efence],
       CFLAGS="$CFLAGS -include stdlib.h -include efence.h"
  ],
  [dnl action-if-not-given
       test "$dynamic" = "true" || LDFLAGS="$LDFLAGS -static"
  	true
  ]
)

+2 −2
Original line number Diff line number Diff line
@@ -5,11 +5,11 @@
** Login   <seblu@epita.fr>
**
** Started on  Thu Aug  3 05:29:46 2006 Seblu
** Last update Sat Aug 19 01:57:49 2006 Seblu
** Last update Tue Nov 14 15:37:34 2006 seblu
*/

#include <string.h>
#include "common.h"
#include "function.h"

char		*basename(const char *path)
{

src/common/env.c

0 → 100644
+60 −0
Original line number Diff line number Diff line
/*
** env.c for 42sh
**
** Made by seblu
** Login   <seblu@epita.fr>
**
** Started on  Tue Nov 14 14:38:42 2006 seblu
** Last update Tue Nov 14 15:37:46 2006 seblu
*/

#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include "function.h"

int		setenv2(char	*name,
			char	*value,
			int	overwrite)
{
  extern char	**environ;
  char		*buf;
  char		**env = environ;
  size_t	len;

  assert(name && value && env);
  len = strlen(name);
  if (!overwrite)
    for (; *env; ++env)
      if (!strncmp(name, *env, len) && (*env)[len] == '=')
	return 1;
  buf = strmerge(3, name, "=", value);
  return !putenv(buf) ? 0 : 2;
}

int		unsetenv2(const char *name)
{
  extern char	**environ;
  size_t	len;
  char		**ep = environ;
  char		**dp = ep;

  if (name == NULL || *name == '\0' || strchr(name, '=') != NULL)
  {
    errno = EINVAL;
    return -1;
  }
  len = strlen(name);
  for (; *ep; ++ep)
  {
    if (!strncmp(*ep, name, len) && (*ep)[len] == '=')
    {
      dp = ep;
      do
	dp[0] = dp[1];
      while (++dp, *dp);
    }
  }
  return 0;
}
Loading