Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firmware
FFS Gluon
Commits
c8bc4620
Unverified
Commit
c8bc4620
authored
8 years ago
by
Matthias Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
gluon-core: unify indentation in gluon/util.lua
parent
849af9ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
+25
-25
25 additions, 25 deletions
package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
with
25 additions
and
25 deletions
package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
+
25
−
25
View file @
c8bc4620
-- Writes all lines from the file input to the file output except those starting with prefix
-- Writes all lines from the file input to the file output except those starting with prefix
-- Doesn't close the output file, but returns the file object
-- Doesn't close the output file, but returns the file object
local
function
do_filter_prefix
(
input
,
output
,
prefix
)
local
function
do_filter_prefix
(
input
,
output
,
prefix
)
local
f
=
io.open
(
output
,
'w+'
)
local
f
=
io.open
(
output
,
'w+'
)
local
l
=
prefix
:
len
()
local
l
=
prefix
:
len
()
for
line
in
io.lines
(
input
)
do
for
line
in
io.lines
(
input
)
do
if
line
:
sub
(
1
,
l
)
~=
prefix
then
if
line
:
sub
(
1
,
l
)
~=
prefix
then
f
:
write
(
line
,
'
\n
'
)
f
:
write
(
line
,
'
\n
'
)
end
end
end
end
return
f
return
f
end
end
local
function
escape_args
(
ret
,
arg0
,
...
)
local
function
escape_args
(
ret
,
arg0
,
...
)
if
not
arg0
then
if
not
arg0
then
return
ret
return
ret
end
end
return
escape_args
(
ret
..
"'"
..
string.gsub
(
arg0
,
"'"
,
"'\\''"
)
..
"' "
,
...
)
return
escape_args
(
ret
..
"'"
..
string.gsub
(
arg0
,
"'"
,
"'\\''"
)
..
"' "
,
...
)
end
end
...
@@ -39,32 +39,32 @@ local uci = require('luci.model.uci').cursor()
...
@@ -39,32 +39,32 @@ local uci = require('luci.model.uci').cursor()
module
'gluon.util'
module
'gluon.util'
function
exec
(
...
)
function
exec
(
...
)
return
os.execute
(
escape_args
(
''
,
'exec'
,
...
))
return
os.execute
(
escape_args
(
''
,
'exec'
,
...
))
end
end
-- Removes all lines starting with a prefix from a file, optionally adding a new one
-- Removes all lines starting with a prefix from a file, optionally adding a new one
function
replace_prefix
(
file
,
prefix
,
add
)
function
replace_prefix
(
file
,
prefix
,
add
)
local
tmp
=
file
..
'.tmp'
local
tmp
=
file
..
'.tmp'
local
f
=
do_filter_prefix
(
file
,
tmp
,
prefix
)
local
f
=
do_filter_prefix
(
file
,
tmp
,
prefix
)
if
add
then
if
add
then
f
:
write
(
add
)
f
:
write
(
add
)
end
end
f
:
close
()
f
:
close
()
os.rename
(
tmp
,
file
)
os.rename
(
tmp
,
file
)
end
end
function
readline
(
fd
)
function
readline
(
fd
)
local
line
=
fd
:
read
(
'*l'
)
local
line
=
fd
:
read
(
'*l'
)
fd
:
close
()
fd
:
close
()
return
line
return
line
end
end
function
lock
(
file
)
function
lock
(
file
)
exec
(
'lock'
,
file
)
exec
(
'lock'
,
file
)
end
end
function
unlock
(
file
)
function
unlock
(
file
)
exec
(
'lock'
,
'-u'
,
file
)
exec
(
'lock'
,
'-u'
,
file
)
end
end
function
node_id
()
function
node_id
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment