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》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

C++标准库(第2版)

C++标准库(第2版)

Nicolai M. Josuttis / 侯捷 / 电子工业出版社 / 2015-6 / 186.00元

《C++标准库(第2版)》是全球C++经典权威参考书籍时隔12年,基于C++11标准的全新重大升级。标准库提供了一组公共类和接口,极大地拓展了C++语言核心功能。《C++标准库(第2版)》详细讲解了每一标准库组件,包括其设计目的和方法、复杂概念的剖析、实用而高效的编程细节、存在的陷阱、重要的类和函数,又辅以大量用C++11标准实现的实用代码范例。除覆盖全新组件、特性外,《C++标准库(第2版)》一......一起来看看 《C++标准库(第2版)》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

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

HEX CMYK 互转工具