bash - 适用于 Linux 的 Windows 子系统 - 在启动时将参数传递给命令
问题描述
我目前正在研究如何利用 wsl 来满足我的开发需求。为了做到这一点,我创建了 wsl 以便它与 systemd 一起使用,以启用 microk8s 和其他依赖于 systemd 的服务。
现在这给我带来了一个问题。我希望能够启动 wsl 并导航到我当前所在的目录。现在
wsl /bin/bash
会这样做。不幸的是,bash 将绕过我的 /etc/profile.d 脚本,这将导致我的 init 进程成为一个 wsl 设置而不是 systemd。
现在我可以轻松地将参数传递给 wsl 内的任何 shell 脚本,正如您所期望的那样
例子.sh
echo "Your argument is $1"
example.sh Hello World
# Output
# Your argument is Hello
但由于某种原因,我无法从外面做同样的事情
wsl /path/example.sh Hello
bash -c /paht/example.sh
所有这些调用都不会导致 $1 包含任何内容。任何想法我怎么能做到这一点?
解决方案
推荐阅读
- python - 从雅虎财经获取股票收益日期
- r - 如何根据来自 R 中另一个数据框的信息更改行值
- typescript - 如何处理简单对象的索引签名
- react-native - React-Native,间距和包装在 FlatList 中
- javascript - TypeError:无法读取未定义的属性“变量”
- python - 我怎么知道列表是否在减少?(Python)
- windows-10 - gpg:无法连接到代理:Windows10 上的文件结束错误
- grpc - GRPC RPC 调用延迟
- typescript - 打字稿-将环境声明应用于未知对象
- c++ - 如何在 C++ 中实例化 Octave classdef 对象并调用其方法