Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
A
attic
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
hydrargyrum
attic
Commits
de8d94b8
Commit
de8d94b8
authored
Oct 11, 2020
by
hydrargyrum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log-snippet: fix fail when context went on negative line numbers
parent
7ff699ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
log-snippet/log-snippet.sh
log-snippet/log-snippet.sh
+17
-2
No files found.
log-snippet/log-snippet.sh
View file @
de8d94b8
...
...
@@ -18,6 +18,20 @@ usage () {
EOF
}
max
()
{
val
=
$1
shift
for
arg
do
if
[
"
$arg
"
-gt
"
$val
"
]
then
val
=
$arg
fi
done
echo
"
$val
"
}
# sysexits
EX_USAGE
=
64
...
...
@@ -52,14 +66,15 @@ do
printf
"%s
\n
"
"--"
fi
currentcontext
=
-
$context
startline
=
$(
max 1
$((
lineno
-
context
))
)
currentcontext
=
$((
startline
-
lineno
))
# change IFS to avoid field splitting on read lines
# for example: don't let shell trim trailing whitespace from $line
old
=
"
$IFS
"
IFS
=
sed
-n
"
$
((
lineno
-
context
))
,
$((
lineno
+
context
))
p"
"
$file
"
|
while
read
-r
line
sed
-n
"
$
startline
,
$((
lineno
+
context
))
p"
"
$file
"
|
while
read
-r
line
do
sep
=
-
if
[
"
$currentcontext
"
-eq
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment