ecommon-sh
Shared shell library for Entrez Direct wrappers. This file defines functions and global variables for argument parsing, retry logic, logging, and ENTREZ_DIRECT envelope handling. It is not a normal end-user CLI.
Quick Start
- Command:
source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
- Local file:
/home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
- Observed library version when sourced:
24.0
When To Use This Tool
- Inspect the common behavior inherited by EDirect wrappers such as
ecollect.
- Reuse shared shell functions like
ParseCommonArgs, FinishSetup, RunWithLogging, and WriteEDirect in your own wrappers.
- Understand how EDirect normalizes flags, retries failed EUtils requests, and serializes ENTREZ_DIRECT metadata.
- Debug why multiple EDirect shell scripts share the same option handling, logging, or error-reporting behavior.
Common Patterns
# 1) Source the library and inspect its version variable
source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
printf '%s\n' "$version"
# 2) Minimal wrapper skeleton that reuses common flag parsing and setup
#!/usr/bin/env bash
source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
ParseCommonArgs "$@"
shift "$argsConsumed"
FinishSetup
RunWithLogging nquire -url "$base" einfo.fcgi -db pubmed
# 3) Emit an ENTREZ_DIRECT envelope after a wrapper finishes
source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
WriteEDirect "pubmed" "$web_env" "$qry_key" "$num" "$stp" ""
Recommended Workflow
- Treat
ecommon.sh as a library file and source it into a shell or wrapper script instead of executing it directly.
- Call
ParseCommonArgs "$@" first if you want the standard EDirect flags and remember to shift "$argsConsumed" before handling tool-specific options.
- Run
FinishSetup before network work so base URL, API key, email, and related globals are initialized consistently.
- Reuse
RunWithLogging / retry helpers and WriteEDirect rather than reimplementing that behavior piecemeal.
Guardrails
- Running
bash ecommon.sh or bash ecommon.sh -version is silently unhelpful in this environment: both paths exit with no useful output.
- The
24.0 version string is visible only after sourcing the file or through sibling wrappers that expose it.
- This library relies on mutable global state (
db, input, web_env, qry_key, verbose, tranquil, and others). Source it into a clean shell context or isolate your wrapper logic carefully.
- Many helper functions eventually invoke sibling EDirect tools such as
xtract, transmute, and nquire; sourcing the file does not guarantee those commands are on PATH.
- Autogenerated docs that treat
ecommon.sh as a standalone command are misleading. The meaningful interface here is its function set, not its direct process invocation.
1---
2name: ecommon-sh
3description: Use when auditing or reusing the shared EDirect shell functions that other Entrez Direct wrapper scripts source internally.
4disable-model-invocation: true
5user-invocable: true
6metadata:
7 source: https://skillmd.com/skills/vimalinx/ecommon-sh
8---
9
10# ecommon-sh
11
12Shared shell library for Entrez Direct wrappers. This file defines functions and global variables for argument parsing, retry logic, logging, and ENTREZ_DIRECT envelope handling. It is not a normal end-user CLI.
13
14## Quick Start
15
16- **Command:** `source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh`
17- **Local file:** `/home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh`
18- **Observed library version when sourced:** `24.0`
19
20## When To Use This Tool
21
22- Inspect the common behavior inherited by EDirect wrappers such as `ecollect`.
23- Reuse shared shell functions like `ParseCommonArgs`, `FinishSetup`, `RunWithLogging`, and `WriteEDirect` in your own wrappers.
24- Understand how EDirect normalizes flags, retries failed EUtils requests, and serializes ENTREZ_DIRECT metadata.
25- Debug why multiple EDirect shell scripts share the same option handling, logging, or error-reporting behavior.
26
27## Common Patterns
28
29```bash
30# 1) Source the library and inspect its version variable
31source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
32printf '%s\n' "$version"
33```
34
35```bash
36# 2) Minimal wrapper skeleton that reuses common flag parsing and setup
37#!/usr/bin/env bash
38source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
39
40ParseCommonArgs "$@"
41shift "$argsConsumed"
42FinishSetup
43
44RunWithLogging nquire -url "$base" einfo.fcgi -db pubmed
45```
46
47```bash
48# 3) Emit an ENTREZ_DIRECT envelope after a wrapper finishes
49source /home/vimalinx/miniforge3/envs/bio/bin/ecommon.sh
50WriteEDirect "pubmed" "$web_env" "$qry_key" "$num" "$stp" ""
51```
52
53## Recommended Workflow
54
551. Treat `ecommon.sh` as a library file and source it into a shell or wrapper script instead of executing it directly.
562. Call `ParseCommonArgs "$@"` first if you want the standard EDirect flags and remember to `shift "$argsConsumed"` before handling tool-specific options.
573. Run `FinishSetup` before network work so base URL, API key, email, and related globals are initialized consistently.
584. Reuse `RunWithLogging` / retry helpers and `WriteEDirect` rather than reimplementing that behavior piecemeal.
59
60## Guardrails
61
62- Running `bash ecommon.sh` or `bash ecommon.sh -version` is silently unhelpful in this environment: both paths exit with no useful output.
63- The `24.0` version string is visible only after sourcing the file or through sibling wrappers that expose it.
64- This library relies on mutable global state (`db`, `input`, `web_env`, `qry_key`, `verbose`, `tranquil`, and others). Source it into a clean shell context or isolate your wrapper logic carefully.
65- Many helper functions eventually invoke sibling EDirect tools such as `xtract`, `transmute`, and `nquire`; sourcing the file does not guarantee those commands are on `PATH`.
66- Autogenerated docs that treat `ecommon.sh` as a standalone command are misleading. The meaningful interface here is its function set, not its direct process invocation.