Comments (13)
i'm trying to come up with a replacement for cat and tail, and i'm running into a wall. the way i would go about this including coreutils would be something like the following
also i need help just making sure this works
# list all in a text file piped to lsftr after string $1
# usage: filetowrite="/dir/file"; cat $(filetowrite) | lsftr $(filetowrite) "FILES:"
lsftr() {
i=0
while read -r line; if [ "$2" != $(STDIN) ]; do
i=$((i + 1))
done
tail +$(i) "$1"
}
}
from cpm.
if i'm overcomplicating this, and there's an easy way to do this, please tell me
from cpm.
What is the high level goal here?
from cpm.
Oh, I see. I think it's best to do something like this:
# come up with a more creative name for this function
filelist() {
while IFS= read -r line; do
[ "$line" = "FILE LIST:" ] && break
done
while IFS= read -r line; do
printf "%s\n" "$line"
done
}
@6gk thoughts?
from cpm.
This can be combined into one loop with a flag variable and another conditional, which is probably clearer.
from cpm.
Sage's impl hurts my brain
I guess yours seems fine, will. However I'm still really confused about what's happening, not helped by not even knowing the file format or idea.
from cpm.
See #27, that's where I just went and found the file in question. I think the screenshot is showing the file/command output to be parsed.
from cpm.
from cpm.
Something like this might work:
slacklist() {
pkginfo="/var/whatever/$1"
if [ -f "$pkginfo" ];
unset found
while IFS= read -r line; do
[ "$line" = "FILE LIST:" ] && found=1
[ "$found" ] && printf "%s\n" "$line"
done <"$pkginfo"
else
# error handling
fi
}
Call it as slacklist zsh
, for example.
from cpm.
Unless there there's weird things going on with whitespace (trailing, leading, multiple mid-word, etc), you shouldn't need to specify
IFS=
I almost always do it anyway, just in case for some reason someone has set it to something else in an enclosing scope or outside the script for some reason, that sort of thing.
from cpm.
Sage's impl hurts my brain
i've been overthinking this for months now, so that's a fair opinion
for error handling it should be something of sorts like
(this is in psuedo as i'm away from my cpu atm)
if [ -d /var/pkgthing ]
if [ -f "/var/pkgthing/$1" ]
pem "something happened"
else pem "not in db, try updating"
else pem "no db, are you using slackware?"
from cpm.
also, that var directory is /var/log/packages/PACKAGE
from cpm.
i've put it all together at https://github.com/foxsouns/cpm/tree/slackfiles, i guess ill pr and let reviews happen
from cpm.
Related Issues (16)
- Homebrew support? HOT 1
- Idea: help menu cacti HOT 2
- Support more package manager features HOT 13
- parts of slackware's implimentation depends on things from coreutils, and im not smart enough to fix it on my own.
- apk is using the wrong operator for the count function. HOT 2
- Impossible to implement removing in tce HOT 2
- xbps upgrade also does update HOT 1
- Installation instructions are unnecessary HOT 14
- a list of known, but unimplemented, PM's HOT 8
- Use the resolve() function for more package managers HOT 1
- slackware; no valid package manager HOT 2
- Combine update and upgrade HOT 2
- prt-get and guix do not use $SUDO? HOT 6
- Fedora 36: update and upgrade do the same thing HOT 5
- Multiple package managers on the same machine HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpm.