zhy2on / 42cursus_03_minishell Goto Github PK
View Code? Open in Web Editor NEWsimple shell(bash)
simple shell(bash)
bash-3.2$ echo a | cat <<eof | cat <<abc | echo b
> eof
> abc
b
bash: echo: write error: Broken pipe
minishell(4496,0x10e3d1dc0) malloc: Incorrect checksum for freed object 0x7f949b408320: probably modified after being freed.
Corrupt value: 0x200000000007f949
minishell(4496,0x10e3d1dc0) malloc: *** set a breakpoint in malloc_error_break to debug
정적 변수 선언 없이 함수 인자에 리턴값으로 할당한 값을 넘겨줄 때 오류 발생.
error 케이스로 실행시
환경변수가 총 16 글자 일때 만 에러가 발생 ( 나머지 경우는 운이 좋아서 된거인가요?)
minishell$ export TEST=/Users/zhy2on/t
minishell$ echo $TEST
/Users/zhy2on/t
minishell$ echo $TEST
minishell(10528,0x100d38580) malloc: Heap corruption detected, free list is damaged at 0x6000005b0190
*** Incorrect guard value: 75818854908160
minishell(10528,0x100d38580) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort ./minishell
특정 문자열 길이에서 free 오류 발생;;
/* error case */
void str_to_token_sub(t_mini *mini, char *str, char *ret)
{
char *value;
char *s;
while (*str)
{
if (*str == - '$')
{
value = search_dollar_value(mini, str);
s = value;
while (s && *s)
*ret++ = *s++;
free(value);
str = end_of_dollar(str);
}
else if (*str == - '>' || *str == - '<'
|| *str == - '&' || *str == - '|')
{
*str = -(*str);
*ret++ = *str;
}
*ret++ = *str++;
}
*ret = '\0';
}
it's now working friend!
bash output : =lol
your output : �TEST=lol
if i set TEST env to abc then,
bash output : abc�TEST=lolabc
your output : abcabc=lolabc
exit print 하는 fd STDERR로 안 돼있는 것들 바꿔야 함
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.