resholved: a Bash linker

栏目: IT技术 · 发布时间: 4年前

内容简介:Quick demonstration of a WIP Python script that leverages the Oil shell's parser to resolve some external shell script dependencies.To run the demo:But, in any case, here's the output:

resholved - a shell resolver? :)

Quick demonstration of a WIP Python script that leverages the Oil shell's parser to resolve some external shell script dependencies.

To run the demo:

git clone https://github.com/abathur/resholved.git
cd resholved
nix-shell --run "./demo"

But, in any case, here's the output:

$ nix-shell --run "./demo"
-- Resolving less_simple_success_a.sh ------------------------------------------
Resolver command: python2 resholver.py --allow PWD < less_simple_success_a.sh
--- less_simple_success_a.sh    2020-02-24 11:41:23.889812868 -0600
+++ /dev/fd/63  2020-02-24 11:59:04.331077380 -0600
@@ -1,5 +1,5 @@
 source simple_fail_a.sh
 which(){
    # resolves file here too
-   file "$@"
+   /nix/store/ckaibpafaixfdnnf6d47qps7wd0107rl-file-5.37/bin/file "$@"
 }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving less_simple_success_b.sh ------------------------------------------
Resolver command: python2 resholver.py --allow PWD < less_simple_success_b.sh
--- less_simple_success_b.sh    2020-02-24 11:40:54.977083198 -0600
+++ /dev/fd/63  2020-02-24 11:59:04.562325589 -0600
@@ -1,4 +1,4 @@
 # var isn't actually checked here
-file $HOME/simple_success_a.sh
+/nix/store/ckaibpafaixfdnnf6d47qps7wd0107rl-file-5.37/bin/file $HOME/simple_success_a.sh
 # exempted by -allow PWD
 source $PWD/simple_success_a.sh
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving simple_success_a.sh -----------------------------------------------
Resolver command: python2 resholver.py --allow PWD < simple_success_a.sh
--- simple_success_a.sh 2020-02-24 11:42:57.440617513 -0600
+++ /dev/fd/63  2020-02-24 11:59:04.706469688 -0600
@@ -1,2 +1,2 @@
 # resolves file from inputs
-file resholver.py
+/nix/store/ckaibpafaixfdnnf6d47qps7wd0107rl-file-5.37/bin/file resholver.py
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving simple_success_b.sh -----------------------------------------------
Resolver command: python2 resholver.py --allow PWD < simple_success_b.sh
--- simple_success_b.sh 2020-02-24 11:43:15.879785108 -0600
+++ /dev/fd/63  2020-02-24 11:59:04.877974130 -0600
@@ -1,2 +1,2 @@
 # resolves gettext from inputs
-source gettext.sh
+source /nix/store/8wn0zg0jx82kqh7aymnd860mkqvkib3s-gettext-0.19.8.1/bin/gettext.sh
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving less_simple_fail_a.sh ---------------------------------------------
Original file:
> source simple_success_a.sh
> file(){
>   # no inputs provide which
>   command which "$@"
> }

Resolver command: python2 resholver.py --allow PWD < less_simple_fail_a.sh
Output:
    command which "$@"
            ^~~~~
[ stdinNone ]:4: Can't resolve command 'which' to a known function or executable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving less_simple_fail_b.sh ---------------------------------------------
Original file:
> /usr/bin/which resholver.py

Resolver command: python2 resholver.py --allow PWD < less_simple_fail_b.sh
Output:
  /usr/bin/which resholver.py
  ^~~~~~~~~~~~~~
[ stdinNone ]:1: Unexpected absolute command path (not supplied by a listed dependency). You should patch/substitute it.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving less_simple_fail_c.sh ---------------------------------------------
Original file:
> # fails because $HOME requires a dynamic parse
> # (I can resolve from a dictionary but haven't
> # seen a clear reason to do it...)
> # and isn't exempted with --allow HOME
> source $HOME/simple_success_a.sh

Resolver command: python2 resholver.py --allow PWD < less_simple_fail_c.sh
Output:
  source $HOME/simple_success_a.sh
         ^~~~~
[ stdinNone ]:5: Can't resolve 'source' with an argument that can't be statically parsed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving simple_fail_a.sh --------------------------------------------------
Original file:
> # no inputs provide which
> which resholver.py

Resolver command: python2 resholver.py --allow PWD < simple_fail_a.sh
Output:
  which resholver.py
  ^~~~~
[ stdinNone ]:2: Can't resolve command 'which' to a known function or executable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Resolving simple_fail_b.sh --------------------------------------------------
Original file:
> # fails to resolve this (from inputs, or relative to directory)
> source doesnt_exist.sh

Resolver command: python2 resholver.py --allow PWD < simple_fail_b.sh
Output:
  source doesnt_exist.sh
         ^~~~~~~~~~~~~~~
[ stdinNone ]:2: Unable to resolve source target 'doesnt_exist.sh' to a known file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

以上所述就是小编给大家介绍的《resholved: a Bash linker》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

深入理解Java虚拟机(第2版)

深入理解Java虚拟机(第2版)

周志明 / 机械工业出版社 / 2013-9-1 / 79.00元

《深入理解Java虚拟机:JVM高级特性与最佳实践(第2版)》内容简介:第1版两年内印刷近10次,4家网上书店的评论近4?000条,98%以上的评论全部为5星级的好评,是整个Java图书领域公认的经典著作和超级畅销书,繁体版在台湾也十分受欢迎。第2版在第1版的基础上做了很大的改进:根据最新的JDK 1.7对全书内容进行了全面的升级和补充;增加了大量处理各种常见JVM问题的技巧和最佳实践;增加了若干......一起来看看 《深入理解Java虚拟机(第2版)》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具