小编Kek*_*eke的帖子

如何在fish shell脚本中设置环境变量

在我的鱼 shell 脚本“hoge.fish”中,我有一个设置环境的代码。

#!/usr/local/bin/fish
set -x HOGE "hello"
Run Code Online (Sandbox Code Playgroud)

但在我执行此脚本后,环境设置不正确并且不输出任何内容。

./hoge.fish
echo $HOGE
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这些代码,但没有一个起作用。

set -gx HOGE "hello"
set -gU HOGE "hello"
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

  • 操作系统:macOS High Sierra10.13.6
  • 鱼版: 2.7.1
  • iTerm2:3.2.0

fish

4
推荐指数
1
解决办法
3312
查看次数

Nginx 返回 200 而不提供文件

我写了这个/etc/nginx/conf.d/apply.conf并启动了nginx。

server {
  location = /hoge {
    return 200;
  }
}
Run Code Online (Sandbox Code Playgroud)

但curl命令失败。

curl localhost:80/hoge
Run Code Online (Sandbox Code Playgroud)

它说

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.13.9</center>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

日志是

open() "/usr/share/nginx/html/hoge" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /hoge HTTP/1.1", host: "localhost"
Run Code Online (Sandbox Code Playgroud)

我只想返回没有响应正文或响应正文为空白的状态代码。

我改成这个但仍然不起作用。

location /hoge {
return 200 'Wow';
add_header Content-Type text/plain;
}
Run Code Online (Sandbox Code Playgroud)

也尝试过这个。

location /hoge {
return 200 'Wow';
default_type text/plain;
}
Run Code Online (Sandbox Code Playgroud)

http nginx http-status-code-404 nginx-location nginx-status

3
推荐指数
1
解决办法
3万
查看次数