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数据结构和算法

Java数据结构和算法

拉佛 / 计晓云 / 中国电力出版社 / 2004-02-01 / 55.00元

《Java数据结构和算法》(第2版)以一种易懂的方式教授如何安排和操纵数据的问题,其中不乏一些难题:了解这些知识以期使计算机的应用获得最好的表现。不管使用何种语言或平台,掌握了数据结构和算法将改进程序的质量和性能。 《Java数据结构和算法》(第2版)提供了一套独创的可视讨论专题用以阐明主要的论题:它使用Java语言说明重要的概念,而避免了C/C++语言的复杂性,以便集中精力论述数据结构和算法。经......一起来看看 《Java数据结构和算法》 这本书的介绍吧!

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

在线压缩/解压 HTML 代码

MD5 加密
MD5 加密

MD5 加密工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具