aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-07-19 16:07:08 +0200
committerCharles <sircharlesaze@gmail.com>2020-07-19 16:07:08 +0200
commited45800a6ad9d4cfbd73832d53e4e26bb7645054 (patch)
treed4691054bba3a7f022eaef0c33763e8322477f7f /src/main.c
parent6e97753fa7307cfc0a2ea426edaac6c683e916f7 (diff)
downloadminishell-ed45800a6ad9d4cfbd73832d53e4e26bb7645054.tar.gz
minishell-ed45800a6ad9d4cfbd73832d53e4e26bb7645054.tar.bz2
minishell-ed45800a6ad9d4cfbd73832d53e4e26bb7645054.zip
Fixing cd error messages, Fixing glob on links
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 332bfee..3d910f8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,7 +6,7 @@
/* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 11:45:44 by cacharle #+# #+# */
-/* Updated: 2020/07/18 08:58:52 by charles ### ########.fr */
+/* Updated: 2020/07/19 15:48:02 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -33,11 +33,10 @@ void ast_print(int level, t_ast *ast);
** cmd variable preprocess
** PATH with no permission, link and other file system fun stuff
** escape lexer
-** escape split preprocessing
+** escape split preprocessing (escaped spaces)
** signal on whole line instead of single command
** parsing error
** env local to current minishell process
-** exit
*/
char *g_basename = "minishell";
@@ -61,6 +60,16 @@ int main(int argc, char **argv, char **envp)
else
g_basename = last_slash + 1;
+ char *pwd_var;
+
+ if ((pwd_var = env_search(env, "PWD")) == NULL)
+ {
+ char buf[PATH_MAX] = {0};
+ if (!(getcwd(buf, PATH_MAX)))
+ return(1);
+ env_export(env, "PWD", buf);
+ }
+
if (argc == 3 && ft_strcmp(argv[1], "-l") == 0)
{
t_ftlst *lex_out = lexer(ft_strdup(argv[2]));