@@ -4,12 +4,12 @@ Category: Develop
44Tags: zsh, operation
55Slug: stderr-check-in-zshell
66Summary: zsh 가상환경 설정한대서 계속 걸쩍지근하게 나오는 에러 문구를 없애고
7- 싶었다.
7+ 싶었다.
88
99Shell로 zsh를 사용중이다. 얼마전부터 개발 환경 설정을 해놓고 이곳저곳에서
1010쓰다보니 해당 개발 환경이 꾸며져있지 않으면, 없다고 해당 문구가 출력된다.
1111
12- ![ stderr] ( {static}/img/2016- 01-26_shell_error .png )
12+ ![ stderr] ( {static}/img/2016/ 01-27/shell_error .png )
1313
1414은근히 신경쓰인다. 만약 두개를 설정해놨는데 둘다 없다면 줄이 두 줄로 늘어난다.
1515
@@ -18,60 +18,67 @@ Shell로 zsh를 사용중이다. 얼마전부터 개발 환경 설정을 해놓
1818우선 Shell에서 기본 I/O 스트림을 통해서 나오는 값들에대해서 다음 숫자로 제어할
1919수 있다.
2020
21- | Handle | Name | Description |
22- | :----: | :--: | :---------: |
23- | 0 | stdin | Standard input |
24- | 1 | stdout | Standard output |
25- | 2 | stderr | Standard error |
21+ | Handle | Name | Description |
22+ | :----: | :---- : | :---- ---------: |
23+ | 0 | stdin | Standard input |
24+ | 1 | stdout | Standard output |
25+ | 2 | stderr | Standard error |
2626
2727간단히 하자.
2828go가 설치되어 있는지 확인을 한다. 제대로 설치됐다면 stdout으로 설치된 경로가 나올 것이다.
2929
30- :::shell
31- $ which go
30+ ``` sh
31+ $ which go
32+ ```
3233
33- ![ ex1_1] ( {static}/img/2016- 01-26_ex1_1 .png )
34+ ![ ex1_1] ( {static}/img/2016/ 01-27/ex1_1 .png )
3435
3536요놈을 안나오게 해보자.
3637
37- :::shell
38- $ which go 1> /dev/null
38+ ``` sh
39+ $ which go 1> /dev/null
40+ ```
3941
40- ![ ex1_2] ( {static}/img/2016- 01-26_ex1_2 .png )
42+ ![ ex1_2] ( {static}/img/2016/ 01-27/ex1_2 .png )
4143
4244오~~~
4345
4446stderr 값이 나오면 안나오게 할려고 보면... 이건 설치가 되어있으니... 없는걸로...
4547
46- :::shell
47- $ which rbenv
48+ ``` sh
49+ $ which rbenv
50+ ```
4851
49- ![ ex2_1] ( {static}/img/2016- 01-26_ex2_1 .png )
52+ ![ ex2_1] ( {static}/img/2016/ 01-27/ex2_1 .png )
5053
5154이걸 위와 같이 ` 1 ` 을 사용하면...
5255
53- :::shell
54- $ which rbenv 1> /dev/null
56+ ``` sh
57+ $ which rbenv 1> /dev/null
58+ ```
5559
56- ![ ex2_2] ( {static}/img/2016- 01-26_ex2_2 .png )
60+ ![ ex2_2] ( {static}/img/2016/ 01-27/ex2_2 .png )
5761
5862음... 출력되는 문구가 stderr로 나오는 건줄 알았는데 아닌갑다. ` 1 ` 로 출력되는걸 막으라했더니...
5963
6064그럼 Python에서는 어디로 나올까?
6165
62- :::python
63- In: import subprocess as sub
64- In: check_rbenv = sub.Popen('which rbenv', stdout=sub.PIPE,
65- stderr=sub.PIPE, shell=True).communicate()
66- In: print(check_rbenv)
67- Out: (b'', b'')
66+ ``` python
67+ In: import subprocess as sub
68+ In: check_rbenv = sub.Popen(
69+ ' which rbenv' , stdout = sub.PIPE , stderr = sub.PIPE , shell = True
70+ ).communicate()
71+ In: print (check_rbenv)
72+ Out: (b ' ' , b ' ' )
73+ ```
6874
6975음?? 암것도 안나온다...
7076
71- :::python
72- In: import os
73- In: os.system('which rbenv')
74- Out: 256
77+ ``` python
78+ In: import os
79+ In: os.system(' which rbenv' )
80+ Out: 256
81+ ```
7582
7683출력값이 256이라니... 혹시나 해서 봤더니 8bit밀란다. 저걸 밀면 1이 떨어지는데...
7784리눅스에서 반환값이 1이면 비정상 종료일때로 알고 있다. 고로니 저넘은 제대로
0 commit comments