oscarmulder / codam-42sh Goto Github PK
View Code? Open in Web Editor NEW42SH is the final (pre-internship) project of the Unix branch at Codam.
42SH is the final (pre-internship) project of the Unix branch at Codam.
There are a few things the termcap functionality does not yet process correctly, since the required functionality is not in place yet.
term_reset (in the file term_reset_attributes
ret = tcsetattr(STDIN_FILENO, TCSANOW, term_p->old_termios_p);
if (ret == -1)
return (FUNCT_SUCCESS);
return (FUNCT_SUCCESS);
codam-42sh/srcs/environment_handling/param_to_env.c
Lines 24 to 27 in 5538350
In principe werkt het maar hier is nog wat er gedaan moet worden:
De laatste pointer uit de history array moet current line worden. Om dat te kunnen doen moet **line, ***line worden. Dat is ook de rede dat ie nu segfault als je arrow up en dan arrow down doet. Volgens mij hoeft er verder niet heel veel gedaan te worden.
TO DO:
1. File isn't in the right directory.
2. It's just inconsistent in general and I've gotten a way better way of doing it now.
At some point we probably have to split up our header file in multiple header files per shell element (parser.h, lexer.h, built-ins etc.)
What should we do when IO_NUMBER exceeds the MAX_INT VALUE when input is given?
edited
For now we won't have to deal with this until the executor
.
codam-42sh/srcs/tools/update_quote_status.c
Lines 27 to 43 in aae15b8
To avoid unnecessary function calling and checking too many things:
int update_quote_status(char *line, int cur_index, char *quote)
{
char c;
c = line[cur_index];
if ((c == '"' || c == '\'') && is_char_escaped(line, cur_index) == false)
{
if (*quote == '\0')
*quote = c;
else
*quote = '\0';
return (FUNCT_SUCCESS);
}
return (FUNCT_FAILURE);
}
Has to be changed to:
commands = (char**)ft_memalloc(sizeof(char*) * (total + 1));
Mandatory part
Modular part 6/6
Bonus
Prerequisites
Actual Bonus
hoi=doei is assignment
"hoi"=doei is not an assignment
hoi="doei" is an assignment
As the title says, the functionality of builtin_exit is not complete yet and should be revamped (although just a small bit).
It currently only prints a new line when called, but should in fact print "exit\n" (bash exit).
So if we do:
echo "echo bullshit'hoi" | bash
We get the output:
bash: line 1: unexpected EOF while looking for matching `'' bash: line 2: syntax error: unexpected end of file
So bash processes the command and finds an error, however the same command piped into vsh:
vsh: STDIN does not refer to a terminal
So we know there is no terminal, but what we should do is process the command anyway.
This will also help to make it possible for fc to reexecute the history commands.
There are some temporary globals and histsize is a fixed number (500)
When the environment is ready this needs to be replaced.
case 1: Resizing the terminal whilst running ls -laR /
causes the output color to turn red (probably because of a shell being printed). If you then ctrl+c
the process, it will not print a prompt, but it will accept input, which will stay in red. On around the third command being entered vsh will segfault.
case 2: Resizing the terminal whilst doing something with a long (or in this case infinite) waiting time like base64 /dev/urandom | rev
, the shell will exit with a few errors: vsh: 0: bad file descriptor
, exit
, and vsh: could not reset terminal settings
@rkuijper, kun jij even uitzoeken of het idd zo is dat bij je termcap functies je eigenlijk ook de `\n`'s of ansi escape of wat dan ook moet meenemen in de input? Op dit moment doe je dat namelijk niet En het lijkt me sterk dat we dat in alle functies moeten toevoegen zoals bij de DLESS en de multiple line commands
This is an issue for multiple reasons, but maybe is fixed in Jorn's version of the env code. Not sure, will check.
Whenever a builtin is successful, do we have to set the *exit_code = EXIT_SUCCESS
when we encounter no problems during execution, or do we only set exit_code whenever something is wrong.
The reason I ask is because exit_code is already set to EXIT_SUCCESS before any command is ran. I can see how we would want to always set it to EXIT_SUCCESS in the builtin function when it is successful though, just to have the code make more sense. Thoughts?
TItle says it all.
res[j] = ft_strsub(s, 0, ft_word_length(s, c));
if (res[j] == NULL)
return (NULL);
Stuff like this, leaks the whole array and all strings in it.
We don't use the return value, it should set exit_code instead.
codam-42sh/srcs/environment_handling/param_to_env.c
Lines 19 to 45 in b5c8158
1
when malloc error occurs in builtins.EXIT_FATAL
when non numeric argument is given to exit2
when multiple arguments are given to exitI think this would be a good idea, any ideas?
We have an enum called e_tokens which is always just 1 of the tokens (it's not used as a flag).
According to the internet: Use a singular name for most Enum types, but use a plural name for Enum types that are bit fields.
So, it would make more sense to call it e_token.
Would like your opinions on this.
PS. The reference I found was describing C#
this needs to be fixed man!!!
Is looping trough a string etc. with str++ acceptable or is this something we want to avoid?
while (*str != '\0')
{
str++;
}
Of alleen
while (str[i] != '\0')
{
i++;
}
example:
if (type == x || type == y)
funct1(type);
funct1(type)
{
if (type != x || type != y) <-----------GOOD OR BAD
return ;
...
}
What are the guidelines regarding commenting functionality?
Are comments unnecessary or are we going to stick to a certain format?
AKA:
/*
** @brief Function description.
** @param 1 Parameter 1 description.
** @param 2 Parameter 2 description.
** @return Return description.
*/
If you have a HISTORY_MAX of 10, and you execute 10 commands (or more). vsh will segfault on exit.
Might be fixed by #235
My gnl is messed up so we need to add another one.
$> ls
riri
$> rm riri; cat riri 2>&-
Here is a representative example of commands your 21sh must be able to execute
correctly:
$> mkdir testdir ; cd testdir ; ls -a ; ls | cat | wc -c > fifi ; cat fifi
. ..
5
$>
It executes ✅
A line edition feature using the termcaps library. Check the following description below:
Regarding the line edition, you must at least manage the following features. The
keys to be used are used as examples, you’re free to use other ones as long as your shell
remains logical and intuitive. The person evaluating you will decide what’s logical and
intuitive, so be careful not to get carried away with creativity.
There are currently 21 norm errors (norminette | grep -E "^Error" | wc -l
)
To see them, execute the following command:
norminette | grep -E "^Error" -B 1 && norminette+ | grep -E "^Error" -B 1
I quickly imported ft_strarradd from my shitty library, it's a bad function but it works. This is issue is to keep a note that it should be rewritten in a more efficient way.
I was looking at the lexer code, and I feel like the naming (state_1, state_2, state_3, ...) should be done better. Most states only do one thing, so...
void state_2(t_scanner *scanner)
{
if (CURRENT_CHAR == '|')
change_state(scanner, &state_3);
else
scanner->tk_type = PIPE;
}
Should in my opinion be changed to:
void state_pipe(t_scanner *scanner)
{
if (CURRENT_CHAR == '|')
change_state(scanner, &state_or_if);
else
scanner->tk_type = PIPE;
}
Or something similar.
Would like your opinions on this.
codam-42sh/srcs/tools/is_char_escaped.c
Lines 28 to 41 in c43ad98
Calling ft_strlen(line) each call of is_char_escaped to check if index is not out of line seems very inefficient. Can we not make sure that line[index] is never out of bounds when we call is_char_escaped?
And:
if (total_escape_chars % 2 == 1)
return (FUNCT_SUCCESS);
else
return (FUNCT_FAILURE);
Could be:
return (total_escape_chars % 2 == 1)
or:
return (total_escape_chars % 2 == 1 ? FUNCT_SUCCESS : FUNCT_FAILURE)
Probably we don't want the last one.
redir_tools2.c
to something that makes more sensecd ../.../
infinite loop\t
and
are valid whitespace in shellget
instead of set
VSCODE-ONLY ERRORS:
@robkuijper please help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.