Conversation
added function that will pull and display MAC address
added function that will pull and display MAC address
|
|
||
| get_hwaddr() { | ||
| hwaddr="$(ip route get 1 | awk '{print $5}')" | ||
| hwaddr="$(ip link show dev "$hwaddr" | awk '/ether/ {print $2}')" |
There was a problem hiding this comment.
A random comment/nit.
You can nest $() blocks, eg:
hwaddr="$(ip link show dev "$(ip route get 1 | awk '{print $5}')" | awk '/ether/ {print $2}')"
This code surprised me a bit. My initial thought was that you would override the previous value.
There was a problem hiding this comment.
I have followed previously set conventions for this project. Please see the 'get_local_ip' function.
There was a problem hiding this comment.
They do different things there. They do bashisms to remove some parts of the string. When they do something similar to what you are doing, they do this:
interface="$(route get 1 | awk -F': ' '/interface/ {printf $2; exit}')"
local_ip="$(ipconfig getifaddr "$interface")"
There was a problem hiding this comment.
Sure, I could make different variables but why would I when this works? Its easy to read and it works well enough. I do appreciate the insights though and will try to incorporate them in future feature implementations.
Description
Only fill in the fields below if relevant.
Features
added function that will pull and display MAC address, mentioned in issue #2454
Issues
TODO